LoadBrush Rotate 180 Degrees

Blitz3D Forums/Blitz3D Programming/LoadBrush Rotate 180 Degrees

jimmyx(Posted 2006) [#1]
Id like to rotate the image screen1.bmp and then
have brush1 store it
brush1 = LoadBrush("screen1.bmp")

how can i rotate the above by 180 degrees


Shifty Geezer(Posted 2006) [#2]
The most obvious straightforward way is to rotate it in a graphics application.


jimmyx(Posted 2006) [#3]
i need rotate this while program is running


Zethrax(Posted 2006) [#4]
Use the RotateTexture command or the RotateImage command.


Beaker(Posted 2006) [#5]
http://www.blitzbasic.com/b3ddocs/command.php?name=GetBrushTexture&ref=3d_cat


jimmyx(Posted 2006) [#6]
couldnt get the RotateTexture command or the RotateImage to work for the line

brush1 = LoadBrush("screen1.bmp")

any ideas


Beaker(Posted 2006) [#7]
Graphics3D 640,480

cam = CreateCamera()
MoveEntity cam,0,0,-4

br = LoadBrush("dirty.png")
cube = CreateCube()
PaintEntity cube,br

tex = GetBrushTexture(br)

While Not KeyDown(1)
	RotateTexture tex,ang
	ang = ang +1
	RenderWorld
	Flip
Wend
End



jimmyx(Posted 2006) [#8]
im trying to rotate a screenshot image
it does not seem to rotate while running


screen1image = LoadBrush("screen1.bmp")
RotateTexture screen1image,180

i need to do this outside the loop main loop
how can i save the rotated image back to
screen1image

thanks


Sir Gak(Posted 2006) [#9]
Are you rotating an image that is the entire size of your display (ie. 640x480, etc)?


jimmyx(Posted 2006) [#10]
the image can be any bmp
im using bmp at the moment


Sir Gak(Posted 2006) [#11]
The Blitz command RotateImage cites: "This command is not fast enough to render rotations in real time!". If you are doing large images, maybe it's just taking a while..........

Possible solution, is to pre-rotate the images you are going to use, and then use them as needed. Of course, you'll want to free up the extra images when you're through using them.


jimmyx(Posted 2006) [#12]
I do not need a real time rotation. and i dont want to
rotate the bmp in photoshop before hand

ill try and explain the situation

ok i have a image a bmp 800x600 at 0 degrees

now before my main loop in the game i need
to turn this bmp 180 degrees and save to variable
brush1 = LoadBrush("screen1.bmp")

basically the image is upside down and need to turn it

thanks guys


Shifty Geezer(Posted 2006) [#13]
You can do a pixel-by-pixel fast copy on locked buffers with this loop

For x = 0 to 800
For y = 0 to 600
CopyPixelFast(x,y,ImageBuffer(source_image),800-x,600-y)
Next
Next

This is probably as fast a 180 degree rotation as you'll get. If you want to flip the image rather than rotate, lose the '800-x' in the destination parameter and just use 'x'.

However B3D's 2D blitting performance seems weak to me. The manual example of this still takes a few milliseconds to copy half a screen of data. I'm unsure why you're wanting to do this. If the image is upside down, why not reverse it before loading it? If the image is the right way up but appears upside down on screen, you're likely drawing your object wrong, such as it being inside out, upside down, or just having wrong UV coords. Or are wanting a copy of the image, so you've right way up and flipped available at the same time?


Zethrax(Posted 2006) [#14]
@jimmyx - You can't rotate a brush. A brush is just a collection of visible attributes that can be applied to something, and which can include a texture. You need to rotate the actual texture image by specifying the texture's handle in the 'RotateTexture' command.

Either explicitly load the texture, using the 'LoadTexture' command, and save the texture handle returned by LoadTexture into an integer variable for later use; or use 'GetBrushTexture' to get a handle to a brush's texture. Note that 'GetBrushTexture' actually creates a new instance of a texture, which you will need to destroy using 'FreeTexture' when you are done with it.

eg. (Untested)

texture_handle = Loadtexture( "mytexture.jpg" )
RotateTexture texture_handle, angle#

--

brush_handle = LoadBrush( "mytexture.jpg" )
texture_handle = GetBrushTexture( brush_handle )
RotateTexture texture_handle, angle#
FreeTexture texture_handle


jimmyx(Posted 2006) [#15]
im going to try this one

hope it works , thanks