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

  • There has been growing buzz about DevOps. DevOps is a methodology that unites the often separate functions of software development (Dev) and production and operations (Ops) into a single, integrated, and continuous process. DevOps is about breaking down the barriers between Dev and Ops. It leverages people, processes, and technology to stimulate collaboration and innovation across the entire software development and release process. Dev and Ops should always be part of an integrated process, but that's not …

  • Live Event Date: May 18, 2015 @ 1:00 p.m. ET / 10:00 a.m. PT While the idea of using facial and or gesture recognitions to create a modern, intuitive game seems attractive, some developers may want to leverage Unity 3D as a way to accelerate their development. There are many different ways in which Intel and Unity Technologies have been working together to helps speed the develop of games with the Intel® RealSense™ SDK (Software Developer Kit), so come hear from a panel of experts on what we've done …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date