Sprite Conversion

BlitzMax Forums/BlitzMax Programming/Sprite Conversion

Nigel Brown(Posted 2009) [#1]
Is it possible to convert from a sprite of type(1) image1=CreateImage( 1024, 768, 1) to type(2) image2=CreateImage(1024,1,768) quickly. I have already created a new image of type(2) and copied from type(1) to the new type(2) image, but this is not fast enough.


ImaginaryHuman(Posted 2009) [#2]
Create pixmaps and keep them and then convert them into images as needed?


Nigel Brown(Posted 2009) [#3]
@ Imaginary, I need TImage as I need to grab the background, unless there is another way?


Bremer(Posted 2009) [#4]
How about Grabpixmap? Does that not grab the background into a pixmap?


Nigel Brown(Posted 2009) [#5]
This code snippet grabs the screen, converts it from a 1024,768,1 TImage to 1024,1,768 TImage result in t:TImage still not sure this is the best way to do it? Pixmaps would be good but cant see a way of making them flexible enough to create multi-framed images?
Local image:TImage = CreateImage( screenWidth, screenHeight, 1)', DYNAMICIMAGE )
GrabImage( image, 0, 0 )
Local pixmap:TPixmap=LockImage(image)

Local x_cells:Int=pixmap.width/screenWidth
Local y_cells:Int=pixmap.height/1
		
Local t:TImage = CreateImage( screenWidth, 1, screenHeight)', DYNAMICIMAGE )

For Local cell:Int=0 To screenHeight-1
	Local x:Int=cell Mod x_cells * screenWidth
	Local y:Int=cell / x_cells * 1
	' selects a specific part of the image into a new pixmap
	Local window:TPixmap=pixmap.Window( x,y,screenWidth,1 )
	t.SetPixmap cell,window.Copy() 'copies the pixmap
Next

UnlockImage(image)