Using seperate file for transparency
Blitz3D Forums/Blitz3D Programming/Using seperate file for transparency
| ||
In order to reduce the file size of my sprites I was planning to make a seperate black and white file, that will define the borders of my sprite. Then I was thinking of compressing the actual sprite to jpg. I would then get blitz to use the transparency information from the black and white file (black being transparent, solid being white). This would mean I wouldn't need a huge BMP file, instead I'd have a small png and a small jpg. So, is there a way to set a texture to use one picture, and then use another just to define transparency? |
| ||
Why not just use a png - they can store transparency, and have lossless compression. |
| ||
I second PNGs, but if you're dead set on this, you can accomplish this by drawing transparent pixels on your sprite texture wherever you find them on your alpha map: load the jpg as your sprite texture load the alpha map as anything readable by ReadPixelFast loop over all the pixels, if ReadPixelFast(alpha map) = black, then WritePixelFast(sprite texture, $FF shl 24) |
| ||
Yeah, PNG is king! I was frankly amazed when I converted my BMPs to lossless PNGs - file sizes were tiny in comparison. |