1 px transparent border to an loaded image
BlitzMax Forums/BlitzMax Beginners Area/1 px transparent border to an loaded image
| ||
Hi ! i want create a new image (34x34 px) into my program with 1 transparent px border. This from another 32x32 px loaded image (with loadimage). How to to this ? CreateImage ? Thanks to post an example ! |
| ||
Hi hub! Sorry, I don't have time for a full example but you can: 1. create the new image by: Fullpixmap:TPixmap=CreatePixmap(32,32,PF_BGR888) 2. Load a tmp image and resize/paste it on the new one. tmppixmap=LoadPixmapJPeg("320x320.jpg") fullpixmap.paste(ResizePixmap(tmppixmap,32,32),0,0) 3. Write the borders via Writpixel in a loop. WritePixel( fullpixmap:TPixmap,x,y,$000000 ) <- Black here. 4. Use MaskPixmap:TPixmap or save the image at the end. Hope that helps a bit. Grisu |
| ||
Thanks Grisu ! |
| ||
Keep in mind that when you load images they increase in size to the next power of 2. So if you load an 34x34 image, you load an 64x64 image into videomemory thus wasting memory. Edit: 34x24 => 34x34 ;) |
| ||
Is that true in both dimentions? Would it not be resized to 34*64? (Still a mem hog, but less so) Or does it depend on the card? |
| ||
You're right, that was a typo, should have been 34x34. |
| ||
@H&K. Bmax makes both pow2 so it would be 64*64. |