ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Inserting image layer with transparency

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
jrpcguru Posted - Mar 24 2019 : 15:56:02
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.
2   L A T E S T    R E P L I E S    (Newest First)
jrpcguru Posted - Mar 25 2019 : 19:40:06
Very nice! Thanks for the help.

J.R.
xequte Posted - Mar 25 2019 : 18:47:17
Hi JR

Yes, getting transparent images out of a TImageList is a bit of a headache. This seems to work consistently:

        ico := TIcon.create;
        iebmp := TIEBitmap.create;
        TImageList( Source ).GetIcon( I , ico );
        iebmp.Assign( ico );
        .. do something with iebmp... 
        ico.Free;
        iebmp.Free;


Note: You can also assign a TImageList to a TImageEnView or TIEMultiBitmap (including the transparency). You can see this in Demos\LayerEditing\Layers_DragDrop\Layers_DragDrop.dpr

Nigel
Xequte Software
www.imageen.com