Bladeren bron

Added FlipY to pixmap.

Mark Sibly 9 jaren geleden
bovenliggende
commit
68a0de3ad4
1 gewijzigde bestanden met toevoegingen van 24 en 0 verwijderingen
  1. 24 0
      modules/std/graphics/pixmap.monkey2

+ 24 - 0
modules/std/graphics/pixmap.monkey2

@@ -103,6 +103,16 @@ Class Pixmap
 		Return _depth
 	End
 	
+	#rem monkeydoc True if pixmap format includes alpha.
+	#end
+	Property HasAlpha:Bool()
+		Select _format
+		Case PixelFormat.A8,PixelFormat.IA16,PixelFormat.RGBA32
+			Return True
+		End
+		Return False
+	End
+	
 	#rem monkeydoc The raw pixmap data.
 	
 	#end
@@ -381,6 +391,20 @@ Class Pixmap
 		End
 	End
 	
+	#rem monkeydoc Flips the pixmap on the Y axis.
+	#end
+	Method FlipY()
+		Local sz:=Width*Depth
+		Local tmp:=New UByte[sz]
+		For Local y:=0 Until Height/2
+			Local p1:=PixelPtr( 0,y )
+			Local p2:=PixelPtr( 0,Height-1-y )
+			libc.memcpy( tmp.Data,p1,sz )
+			libc.memcpy( p1,p2,sz )
+			libc.memcpy( p2,tmp.Data,sz )
+		Next
+	End
+	
 	#rem monkeydoc Returns a rectangular window into the pixmap.
 	
 	In debug builds, a runtime error will occur if the rectangle lies outside of the pixmap area.