rotating a pixmap with alpha by 90 degrees

BlitzMax Forums/BlitzMax Programming/rotating a pixmap with alpha by 90 degrees

Robert Cummings(Posted 2009) [#1]
is this possible?


Jesse(Posted 2009) [#2]
not directly, you can convertit to a image:
image:timage = loadimage(pixmap)
setrotation 90
drawimage image,x,y
I have not tested speed wise but I don't think it's good for real time.
the best way is to work with images

I have code in my signature link under graphics effects that rotate a
pixmap.I optimized it as much as possible but I worn you it's complex and
can be really slow at times. look for antialias_pixmap.rar


Tommo(Posted 2009) [#3]
Just some dirty code.

Updated, it's working properly now...



Function rotatePixmap90:TPixmap(p1:TPixmap, cw:Int)
	Local w:Int, h:Int
	w = p1.width
	h = p1.height
	
	Local p2:TPixmap = CreatePixmap(h, w, p1.format)
	
	Local pitch:Int = p1.pitch
	Local pitch2:Int = p2.pitch
	
	Local l:Int = pitch / w
	Local l2:Int = pitch2 / h 'byte per pixel
	
	Local s:Byte Ptr = p1.pixels
	Local t:Byte Ptr = p2.pixels 'pointers
	
	Local a:Int = w * h * l
	Local a1:Int = h * pitch
	Local off:Int = (a1 - a) / w / l 'alignment
	
	If cw
		s = s + pitch * h + off - l 'seek to last pixel of p1
		
		t = t + pitch2 * (w - 1)
		
		pitch = -pitch
		pitch2 = -pitch2 'backward
		
	Else
		
		s = s + pitch + off - l 'seek to end of firstline  of p1
	EndIf
	
	For Local x:Int = 0 Until w
		Local ss:Byte Ptr = s
		Local tt:Byte Ptr = t
		
		For Local y:Int = 0 Until h
		
			For Local i:Int = 0 Until l
				tt[i] = ss[i]
			Next
			
			ss:+pitch
			tt:+l2
		Next
		
		s:-l
		t:+pitch2
	Next
	
	Return p2
End Function




ImaginaryHuman(Posted 2009) [#4]
Also search for rotating pixmaps with alpha in the forums, I posted some code which does rotation and zooming and alphablending for pixmaps. Or maybe in the code archives. ....


Here:

http://www.blitzbasic.com/Community/posts.php?topic=73042#816898


Robert Cummings(Posted 2009) [#5]
I'll take a look, and thanks for the code :-)