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
 Problem with resampling
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

BionicWave

Germany
33 Posts

Posted - Feb 12 2012 :  04:03:52  Show Profile  Reply
I have the following code:

img := TImageEnView.Create(nil);
img.IO.LoadFromFilePNG(aFileName);
img.Proc.Resample(32,32);
img.IO.SaveToFileICO(ExchangeFileExt(aFileName,'.ico'));
img.Free;

It runs without problems (have try/except and a logging function)
But the resulting ico-file is 64x64!
No matter what i set as a size to resample to.
What am i doing wrong?
I want the icon to be 32x32 pixels in with and height.
Do i have to call another function to fix the size?

thanks

w2m

USA
1990 Posts

Posted - Feb 12 2012 :  06:36:34  Show Profile  Reply
Icons and cursors are a little strange in ImageEN compared to most of the other image types.

// this loads a png file, resamples it to 32x32 and saves the result as an icon
var
  img: TImageEnView;
  aFileName: string;
begin
  img := TImageEnView.Create ( nil );
  try
    if OpenPictureDialog1.Execute then
    begin
      aFileName := OpenPictureDialog1.FileName;
      if LowerCase( ExtractFileExt( aFileName ) ) = '.png' then
      begin
        img.IO.LoadFromFilePNG ( aFileName );
        img.Proc.Resample ( 32, 32, rfNone, True );
        img.IO.Params.ICO_Sizes [ 0 ].cx := 32;
        img.IO.Params.ICO_Sizes [ 0 ].cy := 32;
        img.IO.SaveToFileICO ( ChangeFileExt ( aFileName, '.ico' ) );
      end;
    end;
  finally
    img.Free;
  end; 
end;


... but I am surprised your code even compiles because there is no ExchangeFileExt function that I am aware of... try ChangeFileExt instead.

William Miller
Go to Top of Page

BionicWave

Germany
33 Posts

Posted - Feb 12 2012 :  08:18:44  Show Profile  Reply
That is a function i wrote myself.


Thanks for the answer.
Saved my day.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: