grabpixmap

BlitzMax Forums/BlitzMax Beginners Area/grabpixmap

woolybuger(Posted 2007) [#1]
I have been able to store multi-images in a single .png but I can't find a way to get a sub image out to draw.
grabpixmap seem to be the right command to select a sub image that I want to draw. Then I want to draw the sub image to a specific place. The followinf code get the muti-images loaded:

Local image:timage
Local x,y
Global pixmap:TPixmap
Graphics 800,600

image=LoadImage(LoadPixmapPNG("cimage.png"))

DrawImage image,0,0

Now what do I do to get and draw a sub image from this load to a specific location on the screen


GfK(Posted 2007) [#2]
PixmapWindow is probably what you need.


big10p(Posted 2007) [#3]
DrawImageRect?


woolybuger(Posted 2007) [#4]
thanks, I will look at it

I am trying get around not have an array for images


woolybuger(Posted 2007) [#5]
drawImageRect

draws the all the images in small rectangle not a single image subset


FlameDuck(Posted 2007) [#6]
LoadAnimImage?


woolybuger(Posted 2007) [#7]
Thank FlameDuck. This code worked

load_image=LoadAnimImage:TImage( ("cimage.png"),71,96,0,52,flags=-1 )
DrawImage load_image,0,0
Flip
WaitKey
End

This should allow for an array based indexing of these images and screen placement

Also for annimation storage


woolybuger(Posted 2007) [#8]
Thank FlameDuck. This code worked

load_image=LoadAnimImage:TImage( ("cimage.png"),71,96,0,52,flags=-1 )
DrawImage load_image,0,0
Flip
WaitKey
End

This should allow for an array based indexing of these images and screen placement

Also for annimation storage


GfK(Posted 2007) [#9]
load_image=LoadAnimImage:TImage( ("cimage.png"),71,96,0,52,flags=-1 )

You can remove the highlighted bit in the above code. 'Flags' is the parameter name, -1 is its default value. So if anything it should read "....0,52,-1", but you can just omit the -1 completely. I'm surprised your code didn't throw a type conversion error.


woolybuger(Posted 2007) [#10]
I can only get 15 images from from the stored .png which has 56 image. I did this by a "for" loop that changed the cell first cell parameter from 0 to 14 anything higher caused an error. No error raised on the number of cells.

thank gfk for comment


Yan(Posted 2007) [#11]
That's what the 'frame' parameter of DrawImage() is for...
Strict

Graphics 800, 600, 0

Local image:TImage = LoadAnimImage("cimage.png", 71, 96, 0, 56)

For Local currentFrame=0 To 55
	Cls
	DrawText "Frame " + currentFrame, 12, 12 
	DrawImage image, 100, 100, currentFrame
	Flip
	
	Delay(1000)
Next

End



woolybuger(Posted 2007) [#12]
works great

thanks Ian