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
 Loading and showing icons from EXE file
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

PeterPanino

864 Posts

Posted - May 29 2023 :  10:56:22  Show Profile  Reply
What is the best way to:

1. Load all icons from an EXE file

2. Show them in a MultiView

3. Copy any of them to the clipboard by preserving their transparency

I have looked at the ResourceLoader demo in: Demos\InputOutput\ResourceLoader
I added a Copy button to the ResourceLoader demo:

procedure TMainForm.ButtonCopyClick(Sender: TObject);
begin
  ImageEnView1.Proc.CopyToClipboard();
end;


After having loaded Windows Notepad, I copied its icon and then pasted it into a TImageEnView app:



You can see that the transparency was perfectly preserved.

However, when I paste it into any other Graphics program, the transparency is lost:



I suppose this is because of ImageEnView1.Proc.CopyToClipboard adding the native ImageEn format to the clipboard formats.

So how can I copy the image to the clipboard in a format where any other graphics program recognizes the transparency?

UPDATE: Even when I add the PNG clipboard format by:
IEGlobalSettings().ClipboardCopyFormats := [iefImageEn, iefPNG];
...then several Graphics programs still do not recognize the transparency. Perhaps the Proc Copy clipboard formats should avoid the Bitmap formats and keep only the PNG and ImageEn formats in the clipboard so other programs are not tempted to load the Bitmap formats at pasting?

PeterPanino

864 Posts

Posted - May 29 2023 :  13:56:38  Show Profile  Reply
I have now tried this approach:

procedure TMainForm.ButtonCopyClick(Sender: TObject);
begin
  // Save IEBitmap to MemoryStream as PNG:
  var MemoryStream := TMemoryStream.Create;
  try
    ImageEnView1.IEBitmap.Write(MemoryStream, ioPNG);
    MemoryStream.Position := 0;

    // Load MemoryStream into TPngImage:
    var Png := Vcl.Imaging.pngimage.TPngImage.Create;
    try
      Png.LoadFromStream(MemoryStream);

      // Copy PNG to clipboard:
      Clipboard.Assign(Png);
    finally
      Png.Free;
    end;
  finally
    MemoryStream.Free;
  end;
end;


But it does not work - the image pasted from the clipboard has no transparency:

Go to Top of Page

PeterPanino

864 Posts

Posted - May 29 2023 :  15:15:38  Show Profile  Reply
So I need to copy ONLY these formats from TImageEnView to the clipboard:

PNG
C4FF IMAGEEN RAW FORMAT

...and NOT these formats:

CF_BITMAP
CF_DIB
CF_DIBV

How can this be done?
Go to Top of Page

xequte

38231 Posts

Posted - May 30 2023 :  02:51:37  Show Profile  Reply
Hi Peter

Do those programs support pasting of 8bit alpha images from other applications?

ImageEn's copying functionality cannot be further customized, so you might want to disable the Ctrl+C handling and write your own method for it.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

PeterPanino

864 Posts

Posted - May 30 2023 :  08:37:37  Show Profile  Reply
Hi Nigel

It's not the Ctrl+C handling I'm interested in. It's just a suggestion for Proc.CopyToClipboard: Please add an overload that EXPLICITLY creates only the clipboard formats specified by the user. That would be very helpful.
Go to Top of Page

xequte

38231 Posts

Posted - May 30 2023 :  12:29:21  Show Profile  Reply
Hi Peter

It should not be necessary. The destination application should be iterating through the available formats to use the most compatible one.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

PeterPanino

864 Posts

Posted - Jun 01 2023 :  02:46:23  Show Profile  Reply
This is not the case with some applications like the popular image viewer IrfanView: When pasting an image copied by TImageEnView, the transparency is not preserved. So please add an overload that EXPLICITLY creates only the clipboard formats specified by the user. This would prevent some programs from using the clipboard bitmap formats created by ImageEn (these Bitmap formats do not contain transparency information).
Go to Top of Page

xequte

38231 Posts

Posted - Jun 01 2023 :  03:56:59  Show Profile  Reply
Hi

Have you tested copying content to the clipboard using only PNG format to see whether it changes the way IrfanView supports it. I would be surprised if Irfanview would default to a Bitmap format when a PNG one is supported and available, and if it does you should be reporting it as a bug to the Irfanview developers.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

xequte

38231 Posts

Posted - Jun 02 2023 :  03:18:39  Show Profile  Reply
A user has advised me that IrfanView doesn’t keep the alpha channel in memory (merges it). So pasting PNG is not supported.



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