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
 SaveToFile as Icon

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
jenswahl Posted - Jan 18 2018 : 10:07:15
Hello,

everytime I save a 32x32 pixels png-File as ico-File the result will be a 64x64 pixels ico-file. I use only ImageEnView.IO.SaveToFile(sMyFileNameIco).

How can I get a 32x32 ico-file? See the attached images.

Thank you

Jens





7   L A T E S T    R E P L I E S    (Newest First)
jenswahl Posted - Feb 01 2018 : 01:31:41
Thank you for the tip.

Jens
xequte Posted - Jan 31 2018 : 22:44:37
Hi

The issue is that TImageEnIO requires you to explicitly set the ICO_Sizes if you have not loaded an ICO file:

https://www.imageen.com/help/TIOParams.ICO_Sizes.html

For the next update, we will make it default to the current image size.

Nigel
Xequte Software
www.imageen.com
w2m Posted - Jan 19 2018 : 13:49:23
Follow-up

I have tested adding png images to TImageEnMView and I have found that MIO correctly saves the icon. It appears MIO works correctly but IO does not.
One advantage of using TImageEnMView versus TImageEnView is that saving and loading multiframe icons is much simpler with TImageEnMView than TImageEnView.

procedure TForm1.Add1Click(Sender: TObject);
var
  iFrame: integer;
begin
  if OpenPictureDialog1.Execute then
  begin
    iFrame := ImageEnMView1.AppendImage(OpenPictureDialog1.FileName);
    ImageEnMView1.ImageTopText[iFrame] := 'Frame ' + IntToStr(iFrame+1);
    ImageEnMView1.ImageBottomText[iFrame] := IntToStr(ImageEnMView1.MIO.Params[iFrame].Width) + ' x ' + IntToStr(ImageEnMView1.MIO.Params[iFrame].Height) + ' ' +
      IntToStr(ImageEnMView1.MIO.Params[iFrame].BitsPerSample * ImageEnMView1.MIO.Params[iFrame].SamplesPerPixel) + '-bit';
    ImageEnMView1.CopyToIEBitmap(iFrame, ImageEnView1.IEBitmap);
    ImageEnView1.Update;
    StatusBar1.Panels[2].Text := 'Width: ' + IntToStr(ImageEnMView1.MIO.Params[iFrame].Width);
    StatusBar1.Panels[3].Text := 'Height: ' + IntToStr(ImageEnMView1.MIO.Params[iFrame].Height);
  end;
end;

procedure TForm1.Open1Click(Sender: TObject);
var
  i: integer;
begin
  OpenPictureDialog1.InitialDir := WindowsDesktopFolder;
  if OpenPictureDialog1.Execute then
  begin
    ImageEnMView1.Clear;
    ImageEnMView1.MIO.LoadFromFile(OpenPictureDialog1.FileName);
    for i := 0 to ImageEnMView1.ImageCount-1 do
    begin
      ImageEnMView1.ImageTopText[i] := 'Frame ' + IntToStr(i+1);
      ImageEnMView1.ImageBottomText[i] := IntToStr(ImageEnMView1.MIO.Params[i].Width) + ' x ' + IntToStr(ImageEnMView1.MIO.Params[i].Height) + ' ' +
      IntToStr(ImageEnMView1.MIO.Params[i].BitsPerSample * ImageEnMView1.MIO.Params[i].SamplesPerPixel) + '-bit';
    end;
    ImageEnMView1.SelectedImage := 0;
    ImageEnMView1.CopyToIEBitmap(ImageEnMView1.SelectedImage, ImageEnView1.IEBitmap);
    ImageEnView1.Update;
    Caption := 'Icons- ' + OpenPictureDialog1.FileName;
    StatusBar1.Panels[0].Text := ExtractFileDir(OpenPictureDialog1.FileName);
    StatusBar1.Panels[1].Text := ExtractFileName(OpenPictureDialog1.FileName);
    StatusBar1.Panels[2].Text := 'Width: ' + IntToStr(ImageEnMView1.MIO.Params[ImageEnMView1.SelectedImage].Width);
    StatusBar1.Panels[3].Text := 'Height: ' + IntToStr(ImageEnMView1.MIO.Params[ImageEnMView1.SelectedImage].Height);
  end;
end;

procedure TForm1.Remove1Click(Sender: TObject);
var
  i: integer;
begin
  ImageEnMView1.DeleteImage(ImageEnMView1.SelectedImage);
  ImageEnMView1.Update;
  for i := 0 to ImageEnMView1.ImageCount-1 do
    ImageEnMView1.ImageTopText[i] := 'Frame ' + IntToStr(i+1);
  ImageEnMView1.CopyToIEBitmap(ImageEnMView1.SelectedImage, ImageEnView1.IEBitmap);
  ImageEnView1.Update;
  StatusBar1.Panels[2].Text := 'Width: ' + IntToStr(ImageEnMView1.MIO.Params[ImageEnMView1.SelectedImage].Width);
  StatusBar1.Panels[3].Text := 'Height: ' + IntToStr(ImageEnMView1.MIO.Params[ImageEnMView1.SelectedImage].Height);
end;

procedure TForm1.Save1Click(Sender: TObject);
begin
  ImageEnMView1.MIO.SaveToFile(ImageEnMView1.MIO.Params[0].FileName);
  Caption := 'Icons- ' + ImageEnMView1.MIO.Params[0].FileName;
  StatusBar1.Panels[0].Text := ExtractFileDir(ImageEnMView1.MIO.Params[0].FileName);
  StatusBar1.Panels[1].Text := ExtractFileName(ImageEnMView1.MIO.Params[0].FileName);
  StatusBar1.Panels[2].Text := 'Width: ' + IntToStr(ImageEnMView1.MIO.Params[0].Width);
  StatusBar1.Panels[3].Text := 'Height: ' + IntToStr(ImageEnMView1.MIO.Params[0].Height);
end;

procedure TForm1.SaveAs1Click(Sender: TObject);
begin
  if SavePictureDialog1.Execute then
  begin
    ImageEnMView1.MIO.SaveToFile(SavePictureDialog1.FileName);
    Caption := 'Icons- ' + SavePictureDialog1.FileName;
    StatusBar1.Panels[0].Text := ExtractFileDir(SavePictureDialog1.FileName);
    StatusBar1.Panels[1].Text := ExtractFileName(SavePictureDialog1.FileName);
    StatusBar1.Panels[2].Text := 'Width: ' + IntToStr(ImageEnMView1.MIO.Params[ImageEnMView1.SelectedImage].Width);
    StatusBar1.Panels[3].Text := 'Height: ' + IntToStr(ImageEnMView1.MIO.Params[ImageEnMView1.SelectedImage].Height);
  end;
end;

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
jenswahl Posted - Jan 19 2018 : 04:03:40
Thank you Bill. I'm using version 7.5 too.

Jens
xequte Posted - Jan 18 2018 : 15:34:03
Thanks, I will investigate this when I'm back in the office next week.

Nigel
Xequte Software
www.imageen.com
w2m Posted - Jan 18 2018 : 13:54:21
Followup

The problem seems to be in:
procedure TImageEnIO.SaveToFileICO(const FileName: WideString);
...
while (icount <= high(Params.ICO_Sizes)) and (Params.ICO_Sizes[icount].cx > 0) do
inc(icount);
ICOWriteStream(fs, fIEBitmap, fParams, Progress, slice(Params.ICO_Sizes, icount), slice(Params.ICO_BitCount, icount));
...

For example, when ico_Sizes[0] = 32 the ico is saved as 64 instead of 32. I can not determine why.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
w2m Posted - Jan 18 2018 : 11:18:31
Unfortunately I can confirm this problem. I have never seen this error before. Perhaps something has changed with respect to icon file IO. I tested this with two demos shipped with ImageEn.

I am using IEVersion 7.5. What version are you using?

I'll continue to investigate this problem.

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