补充一下,是在RELEASE版本下保存成功后出错的,GDI+代码如下:
Graphics graph(*MemDC);
Bitmap image(m_picture.GetBitmap(),NULL);
CLSID encoderClsid;
WCHAR str[128];
memset(str,0,128);
// wcscpy(string, m_strSub1Text);
int wlen = MultiByteToWideChar(CP_ACP, 0, sFile, -1,NULL,0);
MultiByteToWideChar(CP_ACP, 0, sFile, strlen(sFile)+1,str,wlen);
// USES_CONVERSION;
GetEncoderClsid(L"image/gif",&encoderClsid);
// image.Save(A2W(m_strFile),& encoderClsid);
image.Save(str,&encoderClsid);
Status sta=image.GetLastStatus();
if(sta!=Ok)
{
AfxMessageBox("Save image Failed !");
}
Graphics graph(*MemDC);
Bitmap image(m_picture.GetBitmap(),NULL);
CLSID encoderClsid;
WCHAR str[128];
memset(str,0,128);
// wcscpy(string, m_strSub1Text);
int wlen = MultiByteToWideChar(CP_ACP, 0, sFile, -1,NULL,0);
MultiByteToWideChar(CP_ACP, 0, sFile, strlen(sFile)+1,str,wlen);
// USES_CONVERSION;
GetEncoderClsid(L"image/gif",&encoderClsid);
// image.Save(A2W(m_strFile),& encoderClsid);
image.Save(str,&encoderClsid);
Status sta=image.GetLastStatus();
if(sta!=Ok)
{
AfxMessageBox("Save image Failed !");
}
解决方案 »
- 指向源图像指针与指向图像像素指针的区别?
- CImage bitblt StretchBlt 造成颜色失真很厉害,应该怎么做,不失真
- 写一个聊天程序时遇见了乱码问题,详情见内
- 关于导出注册表的REG_EXPAND_SZ类型值的问题
- dc
- 初学者的小问题,关于窗口间变量传递
- 各位大虾有没有用过OpenGL开发软件的
- 如何让用户定位一个目录?
- 局域网中的机器能否实现ip伪装?
- 关于XP风格
- 自问自答——关于VC错误:fatal error LNK1104: cannot open file \"mfc42d.lib\"的解决方案
- CArray 二维动态数组,并且定义的是结构体的动态数组,但二维时不能实现?(在线等)
/*
CxImage image;
image.CreateFromHBITMAP(m_picture.GetBitmap());
UINT colors = 250;
CQuantizer q(colors,(colors>16?7:8));
q.ProcessImage(image.GetDIB());
RGBQUAD* ppal=(RGBQUAD*)calloc(256 *sizeof(RGBQUAD),1);
q.SetColorTable(ppal);
image.DecreaseBpp(8,true,ppal,256);
if (ppal) free(ppal);
image.SetTransIndex(1);
RGBQUAD c={255,255,255,0};
image.SetTransColor(c);
if (image.GetBpp()>8){
AfxMessageBox("The image will be saved as a true color GIF!\nThis is ok for CxImage, but not for many other programs.\nFor better compatibility, please use DecreaseBpp to 8 bits or less.",MB_ICONINFORMATION);
return;
}
//修改所用颜色数
//image.head.biClrUsed = image.head.biClrImportant;
image.Save(sFile,CXIMAGE_FORMAT_GIF);
image.Destroy();