How to convert DIB to TPNGObject?

598 views Asked by At

I have a DIB handle. How can I convert it to TPNGObject with preserving its transparency?

EDIT : I use method 2 in this solution Here

but the bitmap resulted is not transparent even if i set its Transparent Flag with true

1

There are 1 answers

3
Marcus Adams On

I think it's going to start out something like this:

var
  lpbi: PBitmapInfoHeader;
begin
  // Get DIB header info from DIB handle
  lpbi := PBitmapInfoHeader(GlobalLock(hdIB));
end;

Then, if it's a 32 bit image, it will have an alpha channel, which you'll use for your transparency data.

Then, you copy the RGB data to the PNG object's scanline and the alpha data to the alpha scanline.