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
 High-quality image format conversion?

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 - Oct 22 2025 : 03:55:27
Does the ImageEn library have a method for high-quality image format conversion, preserving transparency?

I tried this one for converting from Icon to PNG, but it is not optimal:

function IconToPng(AIcon: Vcl.Graphics.TIcon; ASize: Integer): Vcl.Imaging.pngimage.TPngImage;
var
  IEBitmap: TIEBitmap;
  ImageEnIO: TImageEnIO;
  IconStream, PngStream: TMemoryStream;
begin
  Result := TPngImage.Create;
  try
    IEBitmap := TIEBitmap.Create;
    try
      ImageEnIO := TImageEnIO.Create(nil);
      try
        ImageEnIO.AttachedIEBitmap := IEBitmap;

        IconStream := TMemoryStream.Create;
        try
          // Save icon to memory stream
          AIcon.SaveToStream(IconStream);
          IconStream.Position := 0;

          // Load icon with ImageEn (preserves alpha)
          ImageEnIO.LoadFromStreamICO(IconStream);

          // Try Mitchell filter for better quality (good for downsampling)
          // Or try rfBSpline as alternative
          IEBitmap.Resample(ASize, ASize, rfMitchell);

          // Optionally apply slight sharpening after resample
          // IEBitmap.Filter_Sharpen(1);

          // Write directly to PNG stream, then load into TPngImage
          PngStream := TMemoryStream.Create;
          try
            ImageEnIO.SaveToStreamPNG(PngStream);
            PngStream.Position := 0;
            Result.LoadFromStream(PngStream);
          finally
            PngStream.Free;
          end;
        finally
          IconStream.Free;
        end;
      finally
        ImageEnIO.Free;
      end;
    finally
      IEBitmap.Free;
    end;
  except
    Result.Free;
    raise;
  end;
end;
3   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Oct 25 2025 : 20:21:15
As files, streams or in memory bitmaps? All are possible already.



Nigel
Xequte Software
www.imageen.com
PeterPanino Posted - Oct 24 2025 : 16:45:00
Hi Nigel,

This should be a generic function that takes any image format as input and returns any image format as output. That would be very useful.
xequte Posted - Oct 23 2025 : 00:50:27
Hi Peter

Does the result need to be a TPNGImage, or can it be a TIEBitmap?

As you can assign a TIcon to a TIEBitmap just by using aIEBitmap.Assign( AIcon );



Nigel
Xequte Software
www.imageen.com