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
 Extended Dimensions text for ICO frames?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

PeterPanino

526 Posts

Posted - Jun 02 2021 :  15:25:33  Show Profile  Reply
This test project loads the frames from an .ICO file:



I use this code to load the ICO frames:


procedure TForm1.FormCreate(Sender: TObject);
begin
  ImageEnMView1.SetModernStyling();

  ImageEnMView1.DefaultTopText    := iedtFilename; // does not work for image-frames!

  // how to show extended Dimensions info? (Dimensions + color information):
  ImageEnMView1.DefaultBottomText := iedtImageDimensions;

  LoadIcoFile;
end;

procedure TForm1.LoadIcoFile;
var
  i: Integer;
  sFilename: string;
begin
  sFilename := ImageEnMView1.MIO.ExecuteOpenDialog('Select an ICO file', ioICO);
  if sFilename <> '' then
    ImageEnMView1.MIO.LoadFromFile(sFileName);

  // workaround to set the frame-names:
  for i := 0 to ImageEnMView1.ImageCount - 1 do
    ImageEnMView1.ImageTopText[i] := 'Frame ' + IntToStr(i);
end;


Here is the test project:

attach/PeterPanino/202162145958_ExtendedDimensionsText.zip
21.38 KB

As you can see from the above screenshot, there are several frames with the same dimensions which differ by color-depth, as you can see from this screenshot where the same ICO file is loaded in the Axialis Icon Editor:



As you can see, in the Axialis Icon Editor the frames have a text showing the frame dimensions plus the color-depth, for example:

64x64 - RGB/A
265x256 - 16.8 Mio.
64x64 - 256
etc.

...where "RGB/A" probably means 32-bit pixel-format with transparency channel, and "16.8 Mio." probably meaning RGB True Color, and "256" probably meaning 8-Bit color depth?

Is it possible to have such an extended dimensions text also with the image frames loaded from an ICO file?

BTW, here is the ICO file used in the above examples:

attach/PeterPanino/20216215240_test.zip
90.69 KB

PeterPanino

526 Posts

Posted - Jun 02 2021 :  18:16:48  Show Profile  Reply
I now use TIOParams.ICO_BitCount[i] to show the Bit information for each frame:


procedure TForm1.FormCreate(Sender: TObject);
begin
  ImageEnMView1.SetModernStyling();

  ImageEnMView1.DefaultBottomText := iedtImageDimensions;

  LoadIcoFile;
end;

procedure TForm1.LoadIcoFile;
var
  szFilename: string;
  P: TIOParams;
  i: Integer;
begin
  szFilename := ImageEnMView1.MIO.ExecuteOpenDialog('Select an ICO file', ioICO);
  if szFilename <> '' then
    ImageEnMView1.MIO.LoadFromFile(szFilename)
  else
    EXIT;

  P := TIOParams.Create;
  try
    if P.Read(szFilename) then
    begin
      for i := 0 to P.ImageCount - 1 do
      begin
        ImageEnMView1.ImageTopText[i]  := 'Frame ' + IntToStr(i);
        ImageEnMView1.ImageInfoText[i] := IntToStr(P.ICO_BitCount[i]) + '-bit';
      end;
    end;
  finally
    P.Free;
  end;
end;


Is this correct?

However, as you can see in this screenshot, one frame is reported as 21060-bit (!):



Is this a bug?
Go to Top of Page

xequte

6143 Posts

Posted - Jun 03 2021 :  00:03:23  Show Profile  Reply
Hi Pierre

The internal format of icon files is a bit of a dogs breakfast because extended color depth has been added over time, but a lot of icon editors have inconsistently filled the data.

Here is the icon entry for frame 4 of this file:




You should instead use Params.BitsPerSample * Params.SamplesPerPixel.


Note also, you don't need to use an TIOParams object, you can just access the frame TIOParams object, e.g.

procedure TForm1.Button2Click(Sender: TObject);
var
  szFilename: string;
  i: Integer;
begin
  szFilename := ImageEnMView1.MIO.ExecuteOpenDialog('Select an ICO file', ioICO);
  if szFilename = '' then
    EXIT;
  
  ImageEnMView1.MIO.LoadFromFile(szFilename)
  for i := 0 to ImageEnMView1.ImageCount - 1 do
  begin
    ImageEnMView1.ImageTopText[i]  := 'Frame ' + IntToStr(i);
    ImageEnMView1.ImageInfoText[i] := IntToStr( ImageEnMView1.MIO.Params[i].ICO_BitCount[i]) + '-bit';
  end;
end;


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

PeterPanino

526 Posts

Posted - Jun 03 2021 :  05:16:17  Show Profile  Reply
Hi Nigel,

Thank you for the information!

Here is the optimized version which does what I need:


procedure TForm1.FormCreate(Sender: TObject);
begin
  ImageEnMView1.SetModernStyling();
  ImageEnMView1.ThumbnailResampleFilter := rfNone;
  ImageEnMView1.EnableResamplingOnMinor := False;

  ImageEnMView1.DefaultBottomText := iedtImageDimensions;

  LoadIcoFile;
end;

procedure TForm1.LoadIcoFile;
var
  szFilename: string;
  i: Integer;
begin
  szFilename := ImageEnMView1.MIO.ExecuteOpenDialog('Select an ICO file', ioICO);
  if szFilename = '' then EXIT;

  if ImageEnMView1.MIO.LoadFromFile(szFilename) then
  begin
    for i := 0 to ImageEnMView1.ImageCount - 1 do
    begin
      ImageEnMView1.ImageTopText[i]  := 'Frame ' + IntToStr(i);
      ImageEnMView1.ImageInfoText[i] := IntToStr(ImageEnMView1.MIO.Params[i].BitsPerSample * ImageEnMView1.MIO.Params[i].SamplesPerPixel) + '-bit';
    end;
  end;
end;


Go to Top of Page

PeterPanino

526 Posts

Posted - Jun 03 2021 :  05:21:54  Show Profile  Reply
How can I include the transparency information?

There seems to be no alpha-channel information for ICO frames?
Go to Top of Page

xequte

6143 Posts

Posted - Jun 03 2021 :  17:07:08  Show Profile  Reply
Well, it is very wee percentage of icons that are not transparent, so I don't know that it is useful information to display.

The icon has a transparency if HasAlphaChannel is true for the bitmap.

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




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

PeterPanino

526 Posts

Posted - Jun 03 2021 :  18:54:25  Show Profile  Reply
Aren't only 32-bit ICO image-frames that have alpha-channel transparency, as suggested by "RGB/A" in the above Axialis Icon Editor screenshot?
Go to Top of Page

xequte

6143 Posts

Posted - Jun 04 2021 :  19:50:23  Show Profile  Reply
No, Alpha is supported for all bit types in an icon file. The 32bit type supports levels of alpha, whereas other types only support 1bit alpha.



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