This is quite possible but not quite trivial. EMF file is not exactly a container of vector graphical primitive. It is rather a sequence of events and can be "played", much like a video, to get displayed. You can find the EMF's elements by using the method
System.Drawing.Imaging.Metafile.PlayRecord
. See
http://msdn.microsoft.com/en-us/library/system.drawing.imaging.metafile.playrecord.aspx[
^].
[EDIT]
Answering a follow-up question:
There are no pixels in EMF; they are created only when EMF is rendered in screen. The result also depends on the scale you render a metafile — it does not really have its own size.
You need to obtain a bitmap to calculate anything by pixels. You can create a bitmap, obtain an instance of
System.Drawing.Graphics
using
System.Drawing.Graphics.FromImage
. Then, you need to play a metafile on this instance and obtain a pixel graphics in the bitmap. To find pixels, never use
GetPixel
. Always use
System.Drawing.Bitmap.LockBits
, see the code sample here: http://msdn.microsoft.com/en-us/library/5ey6h79d.aspx.
See:
http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.aspx[
^].
—SA