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
 Extended Dimensions text for ICO frames?

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 - Jun 02 2021 : 15:25:33
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
7   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Jun 04 2021 : 19:50:23
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
PeterPanino Posted - Jun 03 2021 : 18:54:25
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?
xequte Posted - Jun 03 2021 : 17:07:08
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
PeterPanino Posted - Jun 03 2021 : 05:21:54
How can I include the transparency information?

There seems to be no alpha-channel information for ICO frames?
PeterPanino Posted - Jun 03 2021 : 05:16:17
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;


xequte Posted - Jun 03 2021 : 00:03:23
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
PeterPanino Posted - Jun 02 2021 : 18:16:48
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?