GDIPLUS in VC6.0 and a small example

xiaoxiao2021-03-06  43

1.GDIPLUS needs to download SDK development package

2. Set the header file path under TOOL, OPTION, Direction, Include Files. . . / Microsoft SDK / INCLUDE, set the lib path under Tool, Option, Direction, Libaray Files. . . / Microsoft SDK / SDK8 / LIB, entered GDIPLUS.LIB in Project, Setting, Link, Object / Modules Libaray.

Note that the path must be placed on the top, and it must be an absolute path, above. . . Need you to add complete

3. Newly built a single document project XXX to add member variables to the XXXAPP class

protected: GdiplusStartupInput m_gdiplusStartupInput; ULONG_PTR m_gdiplusToken; inside added XXXApp :: InitInstance (): GdiplusStartup (& m_gdiplusToken, & m_gdiplusStartupInput, NULL);

Overload xxxapp :: exitInstance (), add: gdiplusshutdown (m_gdiplustoken);

Note that the following statement is added in front of the above modified file:

#include using namespace gdiplus;

The above thing is done, you can use GDIPLUS in the program. The following is a small example of converting BMP into JPG:

INT GETENCODERCLSID (Const Wchar * Format, CLSID * PCLSID) {uint Num = 0; // Number of Image Encoders uint size = 0; // Size of the Image Encoder array in bytes

ImageCodecInfo * pimagecodecinfo = null;

GetImageEncodersSize (& Num, & size); if (size == 0) Return-1; // Failure

PimageCodecInfo = (imagecodecinfo *) (malloc (size)); if (pimagecodecinfo == null) Return -1; // Failure

GetImageEncoders (NUM, SIZE, PIMAGECODECINFO);

For (Uint J = 0; J

Free (pimagecodecinfo); return -1; // failure}

void BMP2JPG (CString strBMPFile, CString strJPGFile) {CLSID encoderClsid; WCHAR strGuid [39]; if (GetEncoderClsid (L "image / jpeg", & encoderClsid)> = 0) StringFromGUID2 (encoderClsid, strGuid, 39); Image image (strBMPFile. AllocsysString (); image.save (strjpgfile.allocsystring (), & encoderclsid, null;} Of course, the above example must be added in front of the file.

#include using namespace gdiplus;

转载请注明原文地址:https://www.9cbs.com/read-51469.html

New Post(0)