Convert BMP to WMF, EXIF, and EMF formats using GDI +

Source: Internet
Author: User
On MSDN, we can see that using the Image: Save method of GDI + can easily Save images as BMP, GIF, TIFF, PNG, and JPEG formats. Although the Metafile class of GDI + allows us to read images in EMF and WMF formats, this class does not directly provide storage methods to write EMF, EXIF, and WMF files. This article introduces another clever writing method.
Use the Bitmap class of GDI + to create an object. After all the drawing operations are completed, a Bitmap is formed. Then input the path of an EMF and other files to be saved. Use an empty file path to construct a Metafile object, use the Metafile object to construct a Graphics drawing object, and draw the source bitmap with DrawImage. The target graph DC is actually an EMF file.
Bitmap
M_Bitmap;
// Bitmap objects that have been drawn or constructed using bitmap files
USES_CONVERSION; // provides A2W macro String Conversion
SFileName =
"C: // test. emf"; // target EMF file path
Metafile
Metafile (A2W (sFileName), cdc-> m_hDC, EmfTypeEmfPlusDual, NULL );
Graphics
Graphics (& metafile );
Graphics. DrawImage (& bmp, 0, 0, bmp. GetWidth (),
Bmp. GetHeight ());

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.