Turn: getcodecclsid - GDIPLUS for providing multiple conversion features

zhaozj2021-02-11  216

The GDI

-------------------------------------------------- ----------------------------- This Article Was Contributed by Leandro Gustavo Biss Becker - Cefet-Pr. Environment: [VC6 SP4, NT4 SP3, W2K, WIN 9X]

I have found that the Microsft GDI can do many cool things for you Previously you had to find code or write your own code to do the same things One of these things is the ability to load or save the following types of images..:

BMP Dib RLEG JPEG EMF TIFF PNG THESE CAN BE LOADED with JUST A FEW LINES OF CODE LIKE THIS:

#include using namespace gdiplus; #pragma comment (lib, "gdiplus.lib")

Image IM (L "C: //fig.jpg", false; clsid gifcodec; getcodecclsid (l "image / gif", & gifcodec; im.save (l "c: //fig.gif", & gifcodec, NULL Here is the code to getcodecclsid

INT getcodecclsid (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 *); if (pimagecodecinfo == null) Return -1; // Failure GetImageEncoders (NUM, SIZE, PIMAGECODECINFO);

For (uint j = 0; j

Return -1; // failure} // getCodecClsid

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

New Post(0)