Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » How to make a non transparent image transparent
Re: How to make a non transparent image transparent [message #32564 is a reply to message #32561] |
Wed, 25 May 2011 08:45   |
|
cbpporter wrote on Tue, 24 May 2011 23:48 | Show it, save it, do normal image stuff with it. I have the code for doing this and I can contribute it if the method does not exist. Wrote it today and generated hundreds of PNGs with it.
My question is: does it exist? If the method exists and I did not find it yet, I need to adapt my code to use the out of the box method.
|
In this case is very easy:
FileIn in(filename);
One<StreamRaster> r = StreamRaster::OpenAny(in);
if(!r)
return Image();
Image img = r->GetImage();
ImageBuffer b(img);
RGBA *s = ~b;
RGBA *e = s + b.GetLength();
RGBA fc;
fc.r = 0;
fc.g = 16;
fc.b = 156;
fc.a = 0;
while(s<e){
if((s->r==fc.r)&&(s->g==fc.g)&&(s->b==fc.b))
s->a=fc.a;
++s;
}
Don't forget to add required packages in your package (e.g.: Draw, plugin/png, plugin/tif, plugin/jpg, ..., etc. ).
|
|
|
Goto Forum:
Current Time: Sun Jun 01 20:09:30 CEST 2025
Total time taken to generate the page: 0.01783 seconds
|