Handling anim images
BlitzMax Forums/BlitzMax Beginners Area/Handling anim images
| ||
| I am trying to create an animation strip from multiple single frame pngs. I make a new image variable: spriteImage = CreateImage(frameWidth * frameCount, frameHeight, frameCount) and use a for loop to add each frame to the newly created image All is fine until this point. Now I want to draw various frames from it and cant do it, frame 0 is the whole image. How do I use this image as an anim image without saving it and loading it with loadanimimage? Is there a way to specify the cell width and height? Thanks. |
| ||
Instead of creating an image, just create a pixmap and paste all your frames in. Then when you are done, use LoadAnimImage() to load the pixmap into the image.Local spritePixmap:TPixmap = CreatePixmap(frameWidth * frameCount, frameHeight, frameCount,PF_RGBA8888)
for Local i:int = 0 Until FrameCount 'in your for/next loop
Local compositeFilename:String = GetCompositeFilename(i) 'get the filename of next image
Local framePixmap:TPixmap = LoadPixmap(filePath + compositeFilename)
If Not framePixmap Then RuntimeError("Something went wrong")
spritePixmap.Paste(framePixmap, currentFrame * framePixmap.Width,0)
Next
Local spriteImage:TImage = LoadAnimImage(spritePixmap,frameWidth,frameHeight,0,frameCount)
spritePixmap = Null 'Free the memory used by the pixmap
|
| ||
| Thank you very much. I didn't know you can pass pixmaps as url in loadanimimage or that you can create a pixmap from loading an image. I thought that if I can pass a pixmap as url I should be able to pass an image as well but that is not the case. Any idea why? I also found another way, I create an image the size of a single frame with proper frame count and instead of pasting the pixmap, i use spriteImage.SetPixmap(currentFrame, framePixmap)It seems that anim images in BlitzMax are just arrays of single frame pixmaps. |