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 开发者_Go百科the src to the dst. i try to copy and draw on canvas but doesn't work with transparent.
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.
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.
精彩评论