Discussion:
Limit on size of EMF (Enhanced Metafile)?
(too old to reply)
Chris Shearer Cooper
2010-03-09 16:13:23 UTC
Permalink
There seems to be a limit on the size of an EMF, but I can't find it
documented anywhere.

I did find this article:

http://support.microsoft.com/kb/904563/

that implies there are issues when the EMF is larger than 2G, but I am
seeing a problem with smaller files (about 500M) where I create the
EMF on disk:
hMetaDC = CreateEnhMetaFile(hRefDC,"c:\\temp\\temp.emf",&rect,NULL);
and then when I want to play back the EMF:
HENHMETAFILE hMeta = CloseEnhMetaFile(hMetaDC);
fails (returns zero) but only when the file is of a sufficient length.

Are there documented limits on the size of an EMF?

Thanks,
Chris
Rene Pilon
2010-03-10 00:52:29 UTC
Permalink
Quick question - does this occur with the same rect when you mention
different sizes?
Out of curiousity - what type of gdi objects are causing the size - bitmaps
or do you have that many records?

Regards,

Rene Pilon
Christian Kaiser
2010-03-11 10:39:50 UTC
Permalink
No, it's possibly defined by the maximum size of contiguous memory you
can allocate in your application ;(. Somehow that affects the EMF
creation (not too surprising, though).

Usually, from our experience which coincide with yours, it's about 500
MB.

Christian
Post by Chris Shearer Cooper
There seems to be a limit on the size of an EMF, but I can't find it
documented anywhere.
http://support.microsoft.com/kb/904563/
that implies there are issues when the EMF is larger than 2G, but I am
seeing a problem with smaller files (about 500M) where I create the
hMetaDC = CreateEnhMetaFile(hRefDC,"c:\\temp\\temp.emf",&rect,NULL);
HENHMETAFILE hMeta = CloseEnhMetaFile(hMetaDC);
fails (returns zero) but only when the file is of a sufficient
length.
Are there documented limits on the size of an EMF?
Thanks,
Chris
Chris Shearer Cooper
2010-03-19 13:08:13 UTC
Permalink
Post by Christian Kaiser
No, it's possibly defined by the maximum size of contiguous memory you
can allocate in your application ;(. Somehow that affects the EMF
creation (not too surprising, though).
Usually, from our experience which coincide with yours, it's about 500
MB.
Christian
Post by Chris Shearer Cooper
There seems to be a limit on the size of an EMF, but I can't find it
documented anywhere.
http://support.microsoft.com/kb/904563/
that implies there are issues when the EMF is larger than 2G, but I am
seeing a problem with smaller files (about 500M) where I create the
hMetaDC = CreateEnhMetaFile(hRefDC,"c:\\temp\\temp.emf",&rect,NULL);
HENHMETAFILE hMeta = CloseEnhMetaFile(hMetaDC);
fails (returns zero) but only when the file is of a sufficient length.
Are there documented limits on the size of an EMF?
Thanks,
Chris
Some additional thoughts ...

* The limit is different if you are creating the metafile in memory
vs. on disk; in most cases it seems smaller for RAM vs. disk (even on
a machine with 3G free RAM my metafile fails at around 300M)

* When creating a metafile on the disk, the file appears to be created
properly (I can look in the folder and see a 800M EMF file), its only
when I try to play it back that the CloseEnhMetaFile() fails. I would
not expect that CloseEnhMetaFile() would need to read the entire EMF
into memory, so the length of the file really shouldn't matter, so I
looked in the EMF header to see if it's doing something like storing
the length of the file in a 24-bit value (and thus overflowing it) but
saw no such thing.

Chris
Christian Kaiser
2010-04-15 14:54:18 UTC
Permalink
Post by Chris Shearer Cooper
* When creating a metafile on the disk, the file appears to be
created
properly (I can look in the folder and see a 800M EMF file), its only
when I try to play it back that the CloseEnhMetaFile() fails. I would
not expect that CloseEnhMetaFile() would need to read the entire EMF
into memory, so the length of the file really shouldn't matter, so I
looked in the EMF header to see if it's doing something like storing
the length of the file in a 24-bit value (and thus overflowing it) but
saw no such thing.
Well CloseEnhMetaFile finishes the EMF file, so it seems the
implementation tries to do that finalization in one big memory chunk,
which cannot be allocated and thus fail.

Christian

Loading...