I am following your suggestion to use ImageEnView1NewLayer to load the image layer with my desired image from an ImageList. That works, though I've been unable to load an image file with a transparent background.
I started with a bmp that is a simple red check mark. Using Photoshop Elements I have made two test PNG files, one that has a transparent background and one that has a white background. If I select the transparent file to add an image layer with your all layers demo, the resulting image layer does have a transparent background.
For my ImageList2, I set colordepth=cd32bit and drawingstyle = dsTransparent.
I've tried a wide variety of combinations of code and I never actually manage to insert my check mark layer with a transparent background. It always inserts with a solid background.
procedure TfrmImagePopUp.ImageEnView1NewLayer(Sender: TObject;
LayerIdx: Integer; LayerKind: TIELayerKind);
var
MyBitMap : TBitMap;
MyIEBitMap : TIEBitMap;
begin
if (ImageEnView1.Layers[LayerIDX].Kind = ielkImage) and (InsertCheckBox1.Checked = true) then
begin
{ try
MyBitMap := TBitmap.Create;
MyBitMap.PixelFormat := pf32bit; //pf24bit
MainForm.ImageList2.GetBitmap(0,MyBitMap); //this loads bitmap, but not with transparent background, even tho original file was .PNG with transparent
TIEImageLayer(ImageEnView1.CurrentLayer).Bitmap.Assign(MyBitMap);
finally
MyBitMap.Free;
end; }
{ try
MyBitMap := TBitmap.Create;
MyBitMap.PixelFormat := pf32bit; //pf24bit
MainForm.PngImageList1.GetBitmap(0,MyBitMap); //this loads bitmap, but not with transparent background, even tho original file was .PNG with transparent
TIEImageLayer(ImageEnView1.CurrentLayer).Bitmap.Assign(MyBitMap);
finally
MyBitMap.Free;
end; }
try //
MyBitMap := TBitmap.Create;
MyBitMap.PixelFormat := pf32bit; //pf24bit
MainForm.PngImageList1.GetBitmap(0,MyBitMap);
MyIEBitMap := TIeBitmap.Create;
MyIEBitMap.PixelFormat := ie32f;
MyIEBitMap.EncapsulateTBitmap(MyBitMap);
// MyIEBitMap.SetTransparentColors(clWhite,clWhite,0);
// MyIEBitMap.SetTransparentColors( CreateRGB(128, 128, 128), CreateRGB(255, 255, 255), 0 );
MyIEBitMap.SetTransparentColors( CreateRGB(255, 255, 255), CreateRGB(255, 255, 255), 0 );
TIEImageLayer(ImageEnView1.CurrentLayer).Bitmap.Assign(MyIEBitMap);
finally
MyBitMap.Free;
MyIEBitMap.Free;
end;
end;
end;
The commented code shows some of the ideas that I've tried. I have also tried the PNGImageList from GetIt but had no better luck. I'm sure hoping there is something simple that I am missing.
J.R.