Find the Mask of an image
BlitzPlus Forums/BlitzPlus Programming/Find the Mask of an image
| ||
I was wondering if its possible to get the RGB values for an images transparent colour |
| ||
Aa i recall there is no native way to do this in b+. However someone might have hacked it into b+ by now. Other then that, you will have to store that information yourself someplace and retrieve it when you need it. |
| ||
one tip is to leave the top left pixel always blank in you images, then you can read the mask value from that. |
| ||
Perhaps it's a lousy solution, but I figure one can't see the difference between 0,0,0 and 1,1,1 ..so I stick to 0,0,0 as mask-always. If I need nonmask-black in my images then I use 1,1,1 .. see no evil. This way I *never* have to think about maskcolors.. it's always 0,0,0 for me.. :P |
| ||
If you're going to use that method use 8,8,8 instead, as 1,1,1 will turn into 0,0,0 in 16 bit graphics modes when you load the images. At least it does in Blitz3D, so I'm assuming the same will happen with BlitzPlus. |
| ||
I had that same 16 bit colour problem, but I think it was fixed as now I always use 255,0,255 (magenta, great for seeing what is background and not in paint package). |
| ||
Unfortunatly I cant use the top-left pixel method since the images I'm working with all tile to make backgrounds The other method could show promise though, I'll have a look |
| ||
I should have said you only need to use the top pixel method if for some reason you haven't used a consistant mask on all you sprites. Using 0,0,0 or a bright colour like 255,0,255 on them all is good. Then you can write a mini function called MyMaskImage(image%) where you pass in the image and mask it to your standard colour like this: MaskImage image,255,0,255. |
| ||
..perhaps store the hex maskcolor in the filename? FF00FF_dragon.bmp etc. |
| ||
good idea. Still using the same one each time is easy too. |