Is there a way to convert a WMF picture to GIF or PNG with the Delphi 2009 (or newer) run time libraries? If not, which image conversion library would you recommend?
+2
A:
PNG is not that hard, Delphi 2009 includes TPNGImage. For GIF you can use GDI+ or the TGifImage component...
Here's the code :
procedure Test;
var
p : TPicture;
png : TPngImage;
begin
try
p := TPicture.Create;
p.LoadFromFile('c:\INPUT.WMF');
png := TPngImage.CreateBlank(COLOR_RGB, 8, p.Width, p.Height);
png.Canvas.Draw(0,0, p.Graphic);
png.SaveToFile('C:\OUTPUT.png');
finally
Free(p);
Free(png);
end;
end;
rep_movsd
2010-03-20 12:07:59
The variable p can also be declared with type TMetafile, this has the advantage that I can also use p.LoadFromStream.
mjustin
2010-03-20 18:09:12
Wouldn't it be better, in general, to create the pngimage after p.width and p.height are initialized by loading input.wmf? Of course this is just demo code.
Argalatyr
2010-03-20 20:54:58