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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 TImageEnMView: Load images from a DLL?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

PeterPanino

934 Posts

Posted - Sep 10 2024 :  02:35:47  Show Profile  Reply
Does TImageEnMView have a built-in method to load the images from an Icon DLL, e.g.:

C:\Windows\System32\imageres.dll

// Does not work:
  ImageEnMView1.MIO.LoadFromFileAuto('C:\Windows\System32\imageres.dll');
  ImageEnMView1.Update;


This would be very useful!

PeterPanino

934 Posts

Posted - Sep 10 2024 :  04:18:11  Show Profile  Reply
I've created a solution that loads the DLL images in TImageEnMView:



Unfortunately, the images are not transparent!

I've attached the project:

attach/PeterPanino/202491041717_TImageEnMViewLoadFromDLL.zip
78 KB

Do you know how to improve this?
Go to Top of Page

PeterPanino

934 Posts

Posted - Sep 10 2024 :  04:48:11  Show Profile  Reply
Even when using the ImageIDRequest trick shown in the documentation, the images are still not transparent:

procedure AddImageListToImageEnMView(ImageList: TImageList; ImageEnMView: TImageEnMView);
var
  i: Integer;
begin
  ImageEnMView.Clear;

  // Add an ID for every bitmap in a TImageList
  for i := 0 to ImageList.Count - 1 do
  begin
    ImageEnMView.InsertImage(I);
    ImageEnMView.ImageID[I] := I;
  end;
end;

procedure TForm1.ImageEnMView1ImageIDRequest(Sender: TObject; Index, ID: Integer; var Bitmap: TBitmap);
begin
  // Retrieve the image from a TImageList
  Bitmap := TBitmap.create;
  ImageList1.GetBitmap(ID, Bitmap);
end;
Go to Top of Page

PeterPanino

934 Posts

Posted - Sep 10 2024 :  05:24:40  Show Profile  Reply
I've finally found the solution to make the images in the ImageEnMView transparent:

procedure AddImageListToImageEnMView(ImageList: TImageList; ImageEnMView: TImageEnMView);
var
  i: Integer;
  Icon: TIcon;
  IEBitmap: TIEBitmap;
begin
  // Clear the TImageEnMView before adding new images
  ImageEnMView.Clear;

  for i := 0 to ImageList.Count - 1 do
  begin
    // Create a new TIcon and retrieve the icon from the ImageList
    Icon := TIcon.Create;
    try
      ImageList.GetIcon(i, Icon);

      // Create a new TIEBitmap to hold the icon image
      IEBitmap := TIEBitmap.Create;
      try
        // Assign the icon directly to the TIEBitmap
        IEBitmap.Assign(Icon);

        // Append the TIEBitmap to the TImageEnMView
        ImageEnMView.AppendImage(IEBitmap);
      finally
        IEBitmap.Free;
      end;
    finally
      Icon.Free;
    end;
  end;

  // Adjust thumbnail settings for better visibility
  ImageEnMView.ThumbWidth := ImageList.Width + 5;
  ImageEnMView.ThumbHeight := ImageList.Height + 5;
  ImageEnMView.HorizBorder := 5;
  ImageEnMView.VertBorder := 5;
end;
Go to Top of Page

PeterPanino

934 Posts

Posted - Sep 10 2024 :  06:22:29  Show Profile  Reply
Now, here is the complete finished working ICON DLL VIEWER project:



attach/PeterPanino/20249106221_TImageEnMViewLoadFromDLL.zip
78.1 KB
Go to Top of Page

xequte

38682 Posts

Posted - Sep 13 2024 :  00:14:18  Show Profile  Reply
Nice one, Peter. Did you try assigning the TImageList to TImageEnMView?

ImageEnMView1.Assign( ImageList1 );

https://www.imageen.com/help/TImageEnMView.Assign.html

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: