CMetaFile class

The CMetaFile class is derived from CMetaFileDC and allows you to easily load metafiles from disk and display them. A metafile can also be displayed with various alignment options, in order to preserve aspect ratio, etc. The class include serialization, allowing you to embed a metafile into a CDocument, for example.

To use the class, simply include "meta.h" and create an instance:

CMetaFile m_meta;

To load a metafile from disk use one of the CMetaFile::Read functions. One takes a pointer to a filename string, the other a pointer to a pre-opened CFile object. The Read function will return FALSE if an error occurred loading the metafile.

If you want to check if a file is a valid metafile, there is a static CMetaFile::IsMetaFile function you can call. Pass a CFile pointer and the function returns true if it's a valid metafile image.

That's about it. The example project shows how to embed a metafile in a document and display it from a view. Examples of all the alignment options are included.

Download Source. and an Example



Comments

  • I wanna Edit EPS File, Modify and Save a new EPS File

    Posted by Legacy on 01/22/2002 12:00am

    Originally posted by: Jes�s Lazo

    I wanna Edit EPS File, Modify and Save it in a new EPS File

    Help me please...

    Reply
  • Bug in Serialize method of CMetaFile class. Memory leak!

    Posted by Legacy on 05/25/2001 12:00am

    Originally posted by: Borissenko Andrey

    ~~~~~~~~~~~~~~~~cut Serialize method~~~~~~~~~~~~~~~~~~~
    else {
    // Load
    // Get the header
    archive.Read(&m_aldusMFHeader, sizeof(m_aldusMFHeader));
    // Get the metafile bits size
    UINT nSize;
    archive >> nSize;
    if (nSize) {
    // Allocate a buffer
    //BYTE* pBits = (BYTE *)GlobalAllocPtr(GHND, nSize);
    BYTE* pBits = new BYTE [nSize];
    if (pBits) {
    // Read bits
    archive.Read(pBits, nSize);
    // Set metafile
    m_emf = ::SetEnhMetaFileBits(nSize, pBits);


    >>>>-----forget delete pBits here---->>>>>>>>>>

    delete [] pBits;

    >>>>-----forget delete pBits here---->>>>>>>>>>


    }
    else {
    // Allocation error
    // Seek past bit data
    CFile* pFile = archive.GetFile();
    if (pFile)
    pFile->Seek(nSize, CFile::current);
    }
    }
    }
    ~~~~~~~~~~~~~~~~ end cut Serialize method~~~~~~~~~~~~~~~~~~~

    Reply
  • WMF from clipboard

    Posted by Legacy on 04/13/2001 12:00am

    Originally posted by: uk

    How can i get a meta file from the clipboard, i want to know the structure of the .wmf file data present in the clipboard.
    please let me know.

    Reply
  • In case of vector wmf ??

    Posted by Legacy on 05/16/2000 12:00am

    Originally posted by: Lee young Sook

    I found that CMetaFile is excellent for image imported WMF.

    However if I try to draw Vector WMF(about 80KB big) on windows98, System resource went down to 0%(on using 'SetWinMetaFileBits' to conver WMF to EMF) and I couldn't see the file.

    If you know why, please reply me.

    Reply
  • I wanna MetaFile To CBitmap Class

    Posted by Legacy on 07/09/1999 12:00am

    Originally posted by: empr


    I wanna MetaFile convert to CBitmap Class.

    help me.. ..Answer.


    Reply
  • Viewing a metafile in a CFormView

    Posted by Legacy on 03/21/1999 12:00am

    Originally posted by: A Schwartz

    How could I insert a metafile (enhanced metafile) into a CFormView? Is it a similar process? Also, inside of the Formview resource, you can create an image of type "Enhanced Metafile", but unfortunately there is no way (that I know of) to import a metafile into the resource. Please respond either here with any suggestions or snippets at my e-mail (anachnujr@aol.com). Thank you!

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: December 11, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Market pressures to move more quickly and develop innovative applications are forcing organizations to rethink how they develop and release applications. The combination of public clouds and physical back-end infrastructures are a means to get applications out faster. However, these hybrid solutions complicate DevOps adoption, with application delivery pipelines that span across complex hybrid cloud and non-cloud environments. Check out this …

  • Organizations need a comprehensive patch management solution which provides endpoint protection beyond the typical operating system in order to effectively and efficiently minimize risks caused by the vulnerabilities that are inevitable in modern computing systems.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds