Creating images from png
BlitzMax Forums/BlitzMax Programming/Creating images from png
| ||
Hi, I have a really long png file which I would like to operate on and cut out images. I will be loading this file as a pixmap (for various reasons). The images will be drawn using DrawImage and use the alpha channel contained within the png file. Ideally I would like to make several images from this file, of varying sizes at runtime. Could you please assist me in this task? Thanks! |
| ||
This is how I'm currently doing it. I guess you can just load the image as a pixmap if you want, and dispense with the LockImage stuff.image.tImage = LoadImage("myImage.png") frame:tImage = LoadImage(PixmapWindow(LockImage(image),x,y,width,height)) |
| ||
This causes my game to crash for some reason at drawimage. Not quite sure why. |
| ||
I have to warn you against this method. It created scrambled graphics on my card with really long source images. I tried both loadpixmap and loadimage as source. Another issue: images don't always get "loaded". You need to pretty much draw straight away on some cards? |
| ||
Possibly a problem with non-square pixmaps then? |
| ||
which is bizarre, because pixmaps are ok non-squared. Hmmm.... I have it working but on this card I *have* to draw it immediately as I grab it into an image or the image is lost (becomes null) and crashes if I try to draw it later. |
| ||
Are you nulling the original pixmap after PixmapWindow? I'm fairly sure you have to leave the original there, as PixmapWindow just creates a pointer to an existing area of memory - once the pixmap is nulled/cleaned up by GC you'll get problems. |