RotateImage ..Strange problum !

Blitz3D Forums/Blitz3D Programming/RotateImage ..Strange problum !

Stickman(Posted 2003) [#1]
I know this is a 2d question but Im using B3D.

When rotating an Image and using Imagehandle() Image size grows and wont stay centered, Why

Try this......
Unless you absoulutly know for fact what Im doing wrong post your answer else please try this first and sit back and watch this for a minute befor ansewing.

I don't want to use MidHandle eather.

; RotateImage Example

 Graphics 640,480,16,2

 gfxBox=CreateImage(50,50)

 SetBuffer ImageBuffer(gfxBox)
 

 Color 255,0,0

 Rect 0,0,50,50,1
 Color 0,0,255
 Rect 1,1,5,5,1
 SetBuffer FrontBuffer()
 


 While Not KeyHit(1)

 Cls

 Color 0,255,255
 Rect 239,279,52,52,0

 DrawImage gfxbox,240,280
 RotateImage gfxBox,-180
 HandleImage gfxbox,0,0

 Color 0,255,0
 Text 200,220," Box Width  "+ImageWidth (gfxbox)
 Text 200,240," Box Height "+ImageHeight(gfxbox)

 ; Delay Start..........
 If start=0
 Delay 3000
 Else If start=1
 Delay 200
 End If 
 start=1

 Wend


Thanks For any help you got........


_Skully(Posted 2003) [#2]
Only set the image handle once and always copy and rotate the image into an array of images. The reason for this is that each time it rotates you will have dithering which will make it look fuzzier and fuzzier. Also, rotateimage by nature is slow. If you rotate them once for every degree of rotation you are interested in then draw that things will be much smoother

; RotateImage Example 

Graphics 640,480,16,2 
Dim images(64)
gfxBox=CreateImage(50,50) 
SetBuffer ImageBuffer(gfxBox) 
Color 255,0,0 
Rect 0,0,50,50,1 
Color 0,0,255 
Rect 1,1,5,5,1 
SetBuffer FrontBuffer() 
HandleImage gfxbox,25,25
For count=0 To 63
	images(count)=CopyImage(gfxbox)
	RotateImage images(count),count*10
Next 

While Not KeyHit(1) 

	For count=0 To 63
		Cls 
		Color 0,255,255 
		Rect 239,279,52,52,0 
		DrawImage images(count),265,305
		Color 0,255,0 
		Text 200,220," Box Width "+ImageWidth (images(count)) 
		Text 200,240," Box Height "+ImageHeight(images(count)) 
		; Delay Start.......... 
		If start=0 
		Else If start=1 
		Delay 200 
		End If 
		start=1 
	Next
Wend 


Skully


Stickman(Posted 2003) [#3]
Very Interesting Example.
Im not actually Rotating the image in real Time ( well kind of )
Im making a texturemap creator ( for my level editor ) and rotating a selected Cropped portion of an Image is a nice feature to add.
I got it worked out now Found that in the Blitz examples and your example,They both used Basickly a MidHandle before rotating,and as I now this worked fine,It was with ImageHandle() that there was trouble.

I only need to rotate the Image in 90deg. incraments that will be activated with a mouseover click.

This was my compromise and well it works fine for what I need it for.


; RotateImage Example

 Graphics 640,480,16,2

 gfxBox=CreateImage(50,50)

 SetBuffer ImageBuffer(gfxBox)
 

 Color 255,0,0

 Rect 0,0,50,50,1
 Color 0,0,255
 Rect 1,1,5,5,1
 SetBuffer FrontBuffer()
 


 While Not KeyHit(1)

 Cls

 Color 0,255,255
 Rect 239,279,52,52,0

 DrawImage gfxbox,240,280
 MidHandle gfxBox          ; <<<< Just Added  "MIDHANDLE"  before Rotate and now works fine.
 RotateImage gfxBox,-90
 HandleImage gfxbox,0,0

 Color 0,255,0
 Text 200,220," Box Width  "+ImageWidth (gfxbox)
 Text 200,240," Box Height "+ImageHeight(gfxbox)

 ; Delay Start..........
 If start=0
 Delay 3000
 Else If start=1
 Delay 200
 End If 
 start=1

 Wend


Thanks : Skully ,for you help.
I appreciate it.