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
 Save a TIEBitmap as a WMF file

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
xequte Posted - Dec 19 2024 : 13:49:15
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