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
 Perfect method for extracting main icon from EXE?

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
PeterPanino Posted - Mar 13 2016 : 17:16:48
I've tried for several hours now, but couldn't get a 100% working and foolproof method to extract the main icon (group) from ANY .EXE file and save it as an .ICO file.

Can anybody help?
6   L A T E S T    R E P L I E S    (Newest First)
w2m Posted - Mar 14 2016 : 13:28:27
I have Axialis IconWorkshop and when I view attach/PeterPanino/20163147846_ExtractedIcon0.zip there are no RGBA 32-bit frames. Here IconWorkShop displays 32bit icons with a white background and all other color depths with a black background.

If you are loading the icons in TImageEnView set the background color to White.

Also if you post your demo source code I can investigate this further. But I believe ImageEn itself is operating as expected as best as I can tell.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
PeterPanino Posted - Mar 14 2016 : 06:29:05
Anyway, now I have generalized the extraction of icons:

procedure TForm1.SaveResourceIcons(const AResourceFile, AExtrIconFile: string);
var
  i: integer;
  j: integer;
  k: integer;
  iResourceExtractor: TIEResourceExtractor;
  iFrames: array of TObject;
  iBuffer: Pointer;
  iBufferLen: integer;
  iFileToSave: string;
  iGroupFrameWidth: integer;
  iGroupFrameHeight: integer;
begin
  iResourceExtractor := TIEResourceExtractor.Create(AResourceFile);
  try
    if iResourceExtractor.IsValid then
    begin
      // search for GroupIcon, loop among Types:
      for i := 0 to iResourceExtractor.TypesCount - 1 do
      begin
        //CodeSite.Send('iResourceExtractor.Types[i]', iResourceExtractor.Types[i]);
        if iResourceExtractor.FriendlyTypes[i] = 'GroupIcon' then
        begin
          //CodeSite.Send('iResourceExtractor.FriendlyTypes[i] = GroupIcon');
          // GroupIcon found, loop among Names
          for j := 0 to iResourceExtractor.NamesCount[i] - 1 do
          begin
            // Allocate array of TImageEnView objects and load frames
            SetLength(iFrames, iResourceExtractor.GroupCountFrames[i, j]);
            for k := 0 to length(iFrames) - 1 do
            begin
              iBuffer := iResourceExtractor.GetFrameBuffer(i, j, k, iBufferLen);
              iFrames[k] := TImageEnView.Create(nil);
              iGroupFrameWidth := iResourceExtractor.GroupFrameWidth[i, j, k];
              iGroupFrameHeight := iResourceExtractor.GroupFrameHeight[i, j, k];
              (iFrames[k] as TImageEnView).IO.Params.IsResource := True;
              (iFrames[k] as TImageEnView).IO.LoadFromBuffer(iBuffer, iBufferLen, ioICO);
              (iFrames[k] as TImageEnView).IO.Params.ICO_Sizes[k].cx := iGroupFrameWidth;
              (iFrames[k] as TImageEnView).IO.Params.ICO_Sizes[k].cY := iGroupFrameHeight;
              (iFrames[k] as TImageEnView).IO.Params.ICO_BitCount[k] := (iFrames[k] as TImageEnView).IO.Params.SamplesPerPixel *
                (iFrames[k] as TImageEnView).IO.Params.BitsPerSample;
            end;

            // Create Multiframe ICO
            iFileToSave := AExtrIconFile + IntToStr(j) + '.ico';
            IEWriteICOImages(iFileToSave, iFrames);

            // Cleanup Frames
            for k := 0 to length(iFrames) - 1 do
              iFrames[k].Free();
          end;
        end;
      end;
    end;
  finally
    iResourceExtractor.Free;
  end;
end;

// usage:
SaveResourceIcons(Trim(Edit1.Text), 'R:\ExtractedIcon');


However, there seems to be an issue with the extracted icons (see attachment):

This is how the icons look when DriveLetterView.exe is directly opened in Axialis IconWorkshop:





And this is how the icons EXTRACTED with the above procedure look in Axialis IconWorkshop:





You can see from the BLACK background in the EXTRACTED icons that there is something wrong with them, as this would make icons with a black content unrecognizable.

attach/PeterPanino/201631463152_extract_icons.zip
147.28 KB

You can also see that the icon extracted from another exe (EssentialPIM.exe) that the RGB/A (32bit with AlphaTransparency) images in the extracted icon are just fine, while the 256 color (8 bit) images have this black background color:

attach/PeterPanino/20163147846_ExtractedIcon0.zip
59.41 KB

So how can this black background be avoided?
PeterPanino Posted - Mar 14 2016 : 04:12:09
You mentioned Resource Extractor, not ResourceLoader.

ResourceLoader shows the icons and Resource Extractor saves the Icon Group.

\ImageEn\Demos\FullApps\ResourceExtractor

As I mentioned in my question, I need to SAVE the main icon, not just to show it.
xequte Posted - Mar 13 2016 : 22:33:33
Hi Peter

Worked fine in my testing (Using the \InputOutput\ResourceLoader demo).



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
PeterPanino Posted - Mar 13 2016 : 18:15:19
Unfortunately, it does not work with this EXE (see attached file).

attach/PeterPanino/2016313181425_BabelPad.zip
3337.64 KB
w2m Posted - Mar 13 2016 : 17:52:19
Give the Resource Extractor demo here: http://www.imageen.com/demos/index.html

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development