//PNG to GIF
#include <Stdio.h>
#include <Objbase.h>
#include <Windows.h>
#include <Gdiplus.h>
#include <GdiPlusEnums.h>
using namespace Gdiplus;
#pragma comment(lib,"gdiplus")
// Helper functions
int GetCodecClsid(const WCHAR*, CLSID*);int main()
{
CoInitialize(NULL);
GdiplusStartupInput gdiplusStartupInput;
ULONG gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
{
CLSID codecClsid;
EncoderParameters encoderParameters;
Status stat;
// Get the CLSID of the JPEG codec.
GetCodecClsid(L"image/gif", &codecClsid);
// An EncoderParameters object has an array of
// EncoderParameter objects. In this case, there is only
// one EncoderParameter object in the array.
encoderParameters.Count = 1;
// Initialize the one EncoderParameter object.
encoderParameters.Parameter[0].Guid = EncoderSaveFlag;
encoderParameters.Parameter[0].Type = EncoderParameterValueTypeLong;
encoderParameters.Parameter[0].NumberOfValues = 1;
encoderParameters.Parameter[0].Value = &encoderParameters;
// Get an image from the disk.
Image image(L"F:\\aaa.png");
stat = image.Save(L"Shapes001.gif", &codecClsid, &encoderParameters);
if(stat == Ok)
wprintf(L"%s saved successfully.\n", L"Shapes001.gif");
else
wprintf(L"%d Attempt to save %s failed.\n", stat, L"Shapes001.gif");
}
GdiplusShutdown(gdiplusToken);
CoUninitialize();
return 0;
} // main
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*)(malloc(size));
if(pImageCodecInfo == NULL)
return -1; // Failure GetImageEncoders(num, size, pImageCodecInfo); for(int j = 0; j < num; ++j)
{
if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 )
{
*pClsid = pImageCodecInfo[j].Clsid;
return j; // Success
}
} // for return -1; // Failure} // GetCodecClsid
#include <Stdio.h>
#include <Objbase.h>
#include <Windows.h>
#include <Gdiplus.h>
#include <GdiPlusEnums.h>
using namespace Gdiplus;
#pragma comment(lib,"gdiplus")
// Helper functions
int GetCodecClsid(const WCHAR*, CLSID*);int main()
{
CoInitialize(NULL);
GdiplusStartupInput gdiplusStartupInput;
ULONG gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
{
CLSID codecClsid;
EncoderParameters encoderParameters;
Status stat;
// Get the CLSID of the JPEG codec.
GetCodecClsid(L"image/gif", &codecClsid);
// An EncoderParameters object has an array of
// EncoderParameter objects. In this case, there is only
// one EncoderParameter object in the array.
encoderParameters.Count = 1;
// Initialize the one EncoderParameter object.
encoderParameters.Parameter[0].Guid = EncoderSaveFlag;
encoderParameters.Parameter[0].Type = EncoderParameterValueTypeLong;
encoderParameters.Parameter[0].NumberOfValues = 1;
encoderParameters.Parameter[0].Value = &encoderParameters;
// Get an image from the disk.
Image image(L"F:\\aaa.png");
stat = image.Save(L"Shapes001.gif", &codecClsid, &encoderParameters);
if(stat == Ok)
wprintf(L"%s saved successfully.\n", L"Shapes001.gif");
else
wprintf(L"%d Attempt to save %s failed.\n", stat, L"Shapes001.gif");
}
GdiplusShutdown(gdiplusToken);
CoUninitialize();
return 0;
} // main
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*)(malloc(size));
if(pImageCodecInfo == NULL)
return -1; // Failure GetImageEncoders(num, size, pImageCodecInfo); for(int j = 0; j < num; ++j)
{
if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 )
{
*pClsid = pImageCodecInfo[j].Clsid;
return j; // Success
}
} // for return -1; // Failure} // GetCodecClsid
http://www.microsoft.com/downloads/release.asp?releaseid=32738
我的email:[email protected],我是VC菜鸟,你能不能做个完整的dll程序发给我,我会把我的可用分都给你。软件的完全要求是:
做一个ASP DLL来转换图形
1)从BLOB载入一个PNG图形
2)转成GIF图形
3)以BLOB形式输出,能够以ASP的Response.BinaryWrite显示