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

  • The nature of the financial services industry places a myriad of international compliance requirements on a company's IT team, as well as an expectation by its customers to deliver the high test levels of performance and reliability. To survive and thrive, businesses in the industry must not only keep pace with customer demand but gain competitive advantage. Those demands mean the IT team must be at the forefront of adopting emerging technologies

  • On-demand Event Event Date: June 23, 2015 Business transformation is not just important, it is vital to the success of all organizations in the 21st century marketplace. How IT approaches and executes the move from cost center to revenue contributor will not only transform the IT organization, it will change how companies retain competitive advantage and meet the requirements of internal and external customers. This shift in thinking is not new, but actualizing it is. Check out this eSeminar to learn the …

Most Popular Programming Stories

More for Developers

RSS Feeds

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