Sorry for the delay in attending, I've been very busy. It seems that we lacked a bit of research.
If the ideal is to work with PNG
because of transparency, then working with Bitmap
is not correct.
In fact, from Delphi 2009
with the introduction of Unicode
It became possible to work with several other types of images, including PNG
.
Here's a question in SOen on TPNGImage
: how-to-get-pngs-to-work-in-d2009
@Guill, you even dealt with the TPNGImage type in your question: # .
At last, my humble method to treat this image:
procedure TMainForm.btnCriarMascaraClick(Sender: TObject);
var
png: TPNGImage;
x,y: TColor;
begin
png := TPNGImage.Create;
try
png.Assign(imgOrig.Picture);
for x := 0 to pred(png.Width) do
for y := 0 to pred(png.Height) do
begin
if png.Pixels[x,y] <> png.TransparentColor then
begin
png.Pixels[x,y] := clLime;
end;
end;
ImgDest.Picture.Assign(png);
finally
png.Free;
end;
end;
Then the result!
You must have unit
pngimage
. In XE3 it is in Vcl.Imaging.pngimage
.
However, if you load the image at the time of desing, the Delphi IDE itself already adds a reference to it.