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
 IEResampleImageFile issue

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
papa.john Posted - Aug 19 2023 : 03:26:42
Hello! I want to create 16x16 icon from PNG image (with transparency) using this function:

IEResampleImageFile('1.png', '1.ico', 0, 16, 16);


The problem is that as a result all transparent areas are replaced with black color. How to make result ico with transparent areas, or at least replace them with white color instead of black?
1   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Aug 19 2023 : 23:32:01
Hi

Please use this updated version of IEResampleImageFile:

function IEResampleImageFile(const sInFilename, sOutFilename: string;
                             JpegQuality: Integer;
                             MaxX, MaxY: Integer;
                             StretchSmall: Boolean = False;
                             QualityFilter: TResampleFilter = rfLanczos3;
                             AutoAdjustOrientation: Boolean = False;
                             bStripMetaData: Boolean = False
                             ): Boolean;
var
  ABitmap: TIEBitmap;
  io: TImageEnIO;
  ASize: TPoint;
begin
  result := true;
  ShowTempHourglass();
  try
    ABitmap := TIEBitmap.create();
    io := TImageEnIO.CreateFromBitmap(ABitmap);                               
    try
      io.Params.GetMetaData := not bStripMetaData;

      // Load full size for best quality (and avoid size discrepency if we are auto-rotating)
      if io.LoadFromFileEx(sInFilename, -1, -1, AutoAdjustOrientation) = False then
        raise EIEException.create( IEExceptionMsg( ieexReadError ));

      if StretchSmall or (ABitmap.width > MaxX) or (ABitmap.height > MaxY) then
      begin
        // Resize the image
        ASize := GetImageSizeWithinArea(ABitmap.Width, ABitmap.Height, MaxX, MaxY);
        ABitmap.Resample(ASize.X, ASize.Y, QualityFilter);
      end;

      if bStripMetaData then
        io.Params.ResetInfo();

      if not io.SaveToFileEx(sOutFilename, JpegQuality) then
        raise EIEException.create( IEExceptionMsg( ieexWriteError ));

    finally
      io.Free;
      ABitmap.Free;
    end;
  except
    result := false;
  end;
end;


Nigel
Xequte Software
www.imageen.com