XBasic3000
XBasic3000

Reputation: 3486

how copy selected area from TPngObject to another TPngObject preserving its transparency

i have two different TPngObject SRC and DST. the SRC has assigned with a PNG graphic.

My code:

dst := TpngImage.createblank(COLOR_RGB, 16, 900, 60);
src.Assign(Image2.Picture.Graphic);

but i need to copy some portion of the src to the dst. i try to copy and draw on canvas but doesn't work with transparent.

Upvotes: 1

Views: 1010

Answers (2)

David Heffernan
David Heffernan

Reputation: 613572

I think you should be able to do this with the AlphaBlend function. You use {SRC/DEST}.Canvas.Handle for the HDC parameters.

I expect you could also achieve this with BitBlt.

I'm still curious as to the value of the TransparencyMode property of your TPNGImage instances.

Upvotes: 2

GrandmasterB
GrandmasterB

Reputation: 3455

I dont use TPNGImage, but I'll take a stab at this... does it support the Pixels property or Scanline? If so, you can copy over only the pixels you want, manually setting the r,g,b, and a values. I do this a lot with pf32bit bitmaps. Drawing it, as you noticed, wont preserve the transparency. You have to set the alpha value manually.

If TPNGImage doesnt support pixels or scanline, you can convert the png's to bitmaps first and do it that way.

Upvotes: 1

Related Questions