TGPImage具有透明颜色?

时间:2019-01-25 10:09:52

标签: delphi transparency gdi+

SELECT to_char(hire_date, 'YYYY') year, to_char(hire_date, 'Month') month, count(*) 
FROM employees 
GROUP BY to_char(hire_date, 'YYYY'), to_char(hire_date, 'Month') 
ORDER BY to_char(hire_date, 'YYYY'), to_date(to_char(hire_date, 'Month'), 'MM');

headingGPImage := TGPImage.Create('heading.bmp'); 图像没有真正的透明度,但是其中一种颜色应视为透明。如何使用TGPImage做到这一点,以便与之传输

heading.bmp

使用透明颜色吗?

1 个答案:

答案 0 :(得分:0)

适用于具有白色背景的png和bmp:

var dest: TGPRect;

attr := TGPImageAttributes.Create;
attr.SetColorKey($FFFFFF, $FFFFFF);
dest.X := 0;
dest.Y := 0;
dest.Width := headingGPImage.GetWidth;
dest.Height := headingGPImage.GetHeight;
GPGraphics.DrawImage(headingGPImage, dest,
     0, 0, Round(headingGPImage.GetWidth), Round(headingGPImage.GetHeight), 
     UnitPixel, 
     attr);