Forum > Graphics

Outputting a transparent PNGimage with BGRABitmap

(1/1)

clintonb:
I have code that used a dll to output a png with transparent pixels but i cant find a .so for linux.  I found an article that shows how to use TBGRABitmap to do this.  I just copied from a control to test it out by saying :

  tempsaveimage.canvas.copyrect(rect(0,0,panel8.width,panel8.height),panelcanvas,rect(0,0,panel8.width,panel8.height));

tempsaveimage.ReplaceColor(BGRA(255,0,0,255),BGRAPixelTransparent);
         

Then i saved it to a file by just calling tempsaveimage.savetofile. 

All works and it actually gives me an output that is a transparent PNG which is great.  What is strange is that imagemagik doesnt recognize the transparency but Gimp does.  Ive spent the last 3 hours comparing a png file that works and the one that i generated with TBGRABitmap and for the life of me i cant see it.  Is this the wrong way to go savethe output to a file? Perhaps there is a pixelformat that needs to be specified?

clintonb:
Its bizarre but i suppose its like saving a jpg with a .bmp extension and certain programs will tell you its not a valid bitmap where others look past the obvious and use the header information.  Its not ideal but opening it in gimp and just re-saving it seems patch what TBGRABitmap misses and everything works.  I will have to dig through this a bit closer to figure just what that is.

TRon:
It is impossible to provide any meaningful feedback without knowing what you actually did in code and what the outcome of it is.

Although there is only a single real one, transparency can mean 2 different things depending on the point of view of whatever program. Note that most graphical viewers/editor do not have a clue (even if they are expensive commercial products).

clintonb:
Im not sure i understand why this is an issue given how many programs had a problem with it but i used the replacecolor to change the background to BGRAPixeltransparent as per a few tutorials and this seems to show opaque.  Looking in Gimp, it is simply a pixel color of black with no opacity or BGRA(0,0,0,0).  Setting this to any non black color with 0 opacity makes the problem go away.

Khrys:
You'll need to show your full/exact code and/or upload the broken  .png  if you want anyone to analyze it further.

Navigation

[0] Message Index

Go to full version