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
 Save a TIEBitmap as a WMF file
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

xequte

38682 Posts

Posted - Dec 19 2024 :  13:49:15  Show Profile  Reply
Note: This is not recommended, as WMF is not a good way to store a raster file

procedure SaveBitmapAsWMF(Bitmap: TBitmap; const FileName: string);
var
  Metafile: TMetafile;
  MetafileCanvas: TMetafileCanvas;
begin
  Metafile := TMetafile.Create;
  try
    Metafile.Enhanced := False; // True for EMF
    Metafile.Width  := Bitmap.Width;
    Metafile.Height := Bitmap.Height;

    MetafileCanvas := TMetafileCanvas.Create( Metafile, 0 );
    try
      // Draw the bitmap onto the metafile canvas
      MetafileCanvas.Draw( 0, 0, Bitmap );
    finally
      MetafileCanvas.Free; 
    end;

    Metafile.SaveToFile( FileName );
  finally
    Metafile.Free();
  end;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
  ImageEnView1.IO.LoadFromFile( 'D:\im.jpg' );
  SaveBitmapAsWMF( ImageEnView1.IEBitmap.VclBitmap, 'D:\output.wmf' );
end;


Nigel
Xequte Software
www.imageen.com
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: