Metafile problem

  • Thread starter Thread starter Jeronimo Bertran
  • Start date Start date
J

Jeronimo Bertran

I am having a problem using DrawImage to scale metafiles. Here is what
I am doing:


Metafile mapImage = new Metafile("C:\\image.wmf");


If I draw the entire metafile it draws correctly:

g.DrawImage(mapImage, 0, 0);


If I try to scale the metafile into the graphic, it does get scaled
correctly but tho origin is moved so what gets drawn in position 0,0 is
not position 0,0 in the metafile even though both rectangles have 0,0
values.

g.DrawImage(bitmapMap, new Rectangle(0, 0, bitmapDest.Width,
bitmapDest.Height), new Rectangle(0, 0, mapImage.Width,
mapImage.Height), GraphicsUnit.Pixel);

In fact the above statement SHOULD display the entire metafile but it
only displays a portion on the lower right corener of the metafile.

Also, if instead of using a metafile, I use a Bitmap, then I don't have
this problem (i.e Bitmap mapImage = new Bitmap("C:\\image.bmp"))

Thanks,

Jeronimo
 
Use an Image, not a metafile?

Image i = Image.FromFile(this.input.FullName, true); // this is whatever image: wmf, emf, bmp
Bitmap b = new Bitmap(i);
Graphics g = Graphics.FromImage(b);
g.Clear(Color.White); // Put the metafile on a background to preserve transparency
g.DrawImage(i, 0, 0);
 
Back
Top