Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Limit on size of EMF (Enhanced Metafile)?

56 views
Skip to first unread message

Chris Shearer Cooper

unread,
Mar 9, 2010, 11:13:23 AM3/9/10
to
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

unread,
Mar 9, 2010, 7:52:29 PM3/9/10
to

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

unread,
Mar 11, 2010, 5:39:50 AM3/11/10
to
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

"Chris Shearer Cooper" <chris.shea...@gmail.com> wrote in
message
news:ccc22956-70ec-4999...@g19g2000yqe.googlegroups.com...

Chris Shearer Cooper

unread,
Mar 19, 2010, 9:08:13 AM3/19/10
to
On Mar 11, 4:39 am, "Christian Kaiser" <b...@gmx.de> wrote:
> 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
>
> "Chris Shearer Cooper" <chris.shearer.coo...@gmail.com> wrote in
> messagenews:ccc22956-70ec-4999...@g19g2000yqe.googlegroups.com...

>
> > 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
>
>

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

unread,
Apr 15, 2010, 10:54:18 AM4/15/10
to

>* 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


0 new messages