用VC++6.0怎么编程实现JPG转换成BMP,求代码,论坛有过类似代码,不过#include <Gdiplus.h>
#include <GdiPlusEnums.h> 两个头文件打不开,不知道是在什么编译器下运行的,我要的是VC++6.谢谢
#include <GdiPlusEnums.h> 两个头文件打不开,不知道是在什么编译器下运行的,我要的是VC++6.谢谢
解决方案 »
- 上次图片没怎么发成功,这次再麻烦高手来看看
- 关于EXE加入DLL资源的问题
- socket缓冲区有什么作用?把socket的recv缓冲区的大小设置为0,照样可以recv数据
- 请教各位高手,HUGE_VAL是什么意思啊?
- vc+mo 如何实现maptips
- 求救:用线程处理防止程序无响应
- -->100分,那我们就来讨论"自动填表"这个问题
- WM_SysCommand 发送 SC_Minimize 给 VC 2003窗口,VC窗口恢复显示后窗口黑屏。
- 更正:是<<深入浅出MFC>>与<<MFC深入浅出--从MFC设计到MFC 编程>> 是否是同一本书?
- 高手请回答:能不能在子Item上也加上checkbox?
- CSDN几百万用户,没有高手了!难道这个问题都解决不了,还是害羞?
- 关于C++中类和对象内存分配问题!!!!!!!!!
我也不知道对不对,硕士说自己的看法吧
希望各路高手能指点下小弟,
有什么好的方法么,要求也是要用vc来完成多格式图像转换
先谢谢各位了
BOOL Jpeg2Bmp(LPCWSTR pJpgFileName, LPCWSTR pBmpFileName);
BOOL Bmp2Jpeg(LPCWSTR pBmpFileName, LPCWSTR pJpgFileName);//jpeglib.cpp
#include "StdAfx.h"
#include "JpegLib.h"#ifndef ULONG_PTR
#define ULONG_PTR unsigned long*
#endif
#include <Gdiplus.h>
#include <GdiPlusEnums.h>
using namespace Gdiplus;
#pragma comment(lib, "gdiplus.lib")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));
pImageCodecInfo = (ImageCodecInfo*)(new BYTE[size]);
if(pImageCodecInfo == NULL)
return -1; // Failure
GetImageEncoders(num, size, pImageCodecInfo);
for(UINT j = 0; j < num; ++j)
{
if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 )
{
*pClsid = pImageCodecInfo[j].Clsid;
return j; // Success
}
} // for
return -1; // Failure
} // GetCodecClsidTopBOOL Jpeg2Bmp(LPCWSTR pJpgFileName, LPCWSTR pBmpFileName)
{
CLSID codecClsid;
EncoderParameters encoderParameters;
long quality;
Status stat;
// Get an image from the disk.
Image image(pJpgFileName);
// Get the CLSID of the JPEG codec.
GetCodecClsid(L"image/bmp", &codecClsid);
// Before we call Image::Save, we must initialize an
// EncoderParameters object. The EncoderParameters object
// has an array of EncoderParameter objects. In this
// case, there is only one EncoderParameter object in the array.
// The one EncoderParameter object has an array of values.
// In this case, there is only one value (of type LONG)
// in the array. We will set this value to 0, 50, and 100.
encoderParameters.Count = 1;
encoderParameters.Parameter[0].Guid = EncoderQuality;
encoderParameters.Parameter[0].Type = EncoderParameterValueTypeLong;
encoderParameters.Parameter[0].NumberOfValues = 1;
// Save the image as a JPEG with quality level 0.
quality = 0;
encoderParameters.Parameter[0].Value = &quality;
stat = image.Save(pBmpFileName, &codecClsid, &encoderParameters); return stat == Ok;
}BOOL Bmp2Jpeg(LPCWSTR pBmpFileName, LPCWSTR pJpgFileName)
{
CLSID codecClsid;
EncoderParameters encoderParameters;
long quality;
Status stat;
// Get an image from the disk.
Image image(pBmpFileName);
// Get the CLSID of the JPEG codec.
GetCodecClsid(L"image/jpeg", &codecClsid);
// Before we call Image::Save, we must initialize an
// EncoderParameters object. The EncoderParameters object
// has an array of EncoderParameter objects. In this
// case, there is only one EncoderParameter object in the array.
// The one EncoderParameter object has an array of values.
// In this case, there is only one value (of type LONG)
// in the array. We will set this value to 0, 50, and 100.
encoderParameters.Count = 1;
encoderParameters.Parameter[0].Guid = EncoderQuality;
encoderParameters.Parameter[0].Type = EncoderParameterValueTypeLong;
encoderParameters.Parameter[0].NumberOfValues = 1;
// Save the image as a JPEG with quality level 0.
quality = 0;
encoderParameters.Parameter[0].Value = &quality;
stat = image.Save(pJpgFileName, &codecClsid, &encoderParameters); return stat == Ok;
}///////////////
it's okay
jpg_bmp.cpp
(2) : error C2146: syntax error : missing ';' before identifier 'Jpeg2Bmp'
(2) : error C2501: 'BOOL' : missing storage-class or type specifiers
(2) : fatal error C1004: unexpected end of file found