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
 SaveToFile as Icon
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

jenswahl

Germany
71 Posts

Posted - Jan 18 2018 :  10:07:15  Show Profile  Reply
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





w2m

USA
1990 Posts

Posted - Jan 18 2018 :  11:18:31  Show Profile  Reply
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
Go to Top of Page

w2m

USA
1990 Posts

Posted - Jan 18 2018 :  13:54:21  Show Profile  Reply
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
Go to Top of Page

xequte

38225 Posts

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

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

jenswahl

Germany
71 Posts

Posted - Jan 19 2018 :  04:03:40  Show Profile  Reply
Thank you Bill. I'm using version 7.5 too.

Jens
Go to Top of Page

w2m

USA
1990 Posts

Posted - Jan 19 2018 :  13:49:23  Show Profile  Reply
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
Go to Top of Page

xequte

38225 Posts

Posted - Jan 31 2018 :  22:44:37  Show Profile  Reply
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
Go to Top of Page

jenswahl

Germany
71 Posts

Posted - Feb 01 2018 :  01:31:41  Show Profile  Reply
Thank you for the tip.

Jens
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: