I am working on a program in Delphi XE2 which needs to be able to convert Windows enhanced metafiles to bitmaps. The following code is used to perform the conversion:
procedure TForm1.Button8Click(Sender: TObject);
var
Bitmap : TBitmap;
Metafile : TMetafile;
begin
Metafile := TMetafile.Create();
Bitmap := TBitmap.Create;
try
Metafile.LoadFromFile(Edit1.Text);
Bitmap.Width := Metafile.Width;
Bitmap.height:= Metafile.Height;
Bitmap.Canvas.Draw(0,0,Metafile);
Bitmap.SaveToFile(ChangeFileExt(Edit1.Text, '.bmp'));
finally
Bitmap.Free();
Metafile.Free();
end;
end;
With certain image files the text, which was quite clear in the original metafile, appears somewhat blurry in the final bitmap. Unfortunately I cannot post an example image here because I don't have sufficient reputation points, however you can see the sort of thing I am talking about if you compare the two images in the following question:
when rendering metafile, the texts are too large
I have tested this on two machines (both Windows 7; one 32-bit, the other 64-bit). The problem only occurs on the 64-bit machine; converting exactly the same image file on the 32-bit machine results in a bitmap with normal-looking text.
Things I have tried so far:
Installed all fonts that were present on the 32-bit machine but not on the 64-bit machine onto the 64-bit machine. The text in the generated bitmap was still blurry.
Tried performing the conversion using the SynGdiPlus library instead of the above code. The text in the generated bitmap was still blurry.
Tried opening the original image file in EMF Explorer. Regardless of whether GDI+ is enabled or not, the text displayed there is non-blurry.
Does anybody have any suggestions as to how I could solve this problem?
Here are the two images:
The version made on the 64 bit machine:
The version made on the 32 bit machine:
For the scenario I am dealing with, I prefer the second image, that made on the 32 bit machine.