首页 > 学院 > 开发设计 > 正文

chromium中从本地加载gif图片

2019-11-06 08:06:31
字体:
来源:转载
供稿:网友
#ifndef min *#define min *#endif *#ifndef max *#define max *#endif *#include <atlimage.h>#undef min *#undef max*// 如果不添加*部分会报 c:/PRogram files (x86)/windows kits/10/include/10.0.10586.0/um/gdiplustypes.h(479): error C3861: 'min': identifier not foundc:/program files (x86)/windows kits/10/include/10.0.10586.0/um/gdiplustypes.h(481): error C3861: 'max': identifier not found// 如上之类的错误 gfx::Image ImageFromLocalGifFile(base::string16 gif_filename) { gfx::Image image; CImage img; if (SUCCEEDED(img.Load(gif_filename.c_str()))) { DWord ulBufferLen = 0; IStream* pOutStream = NULL; if (CreateStreamOnHGlobal(NULL, TRUE, &pOutStream) == S_OK) { img.Save(pOutStream, Gdiplus::ImageFormatJPEG); HGLOBAL hOutGlobal = NULL; GetHGlobalFromStream(pOutStream, &hOutGlobal); LPBYTE pBits = (LPBYTE)GlobalLock(hOutGlobal); ulBufferLen = (DWORD)GlobalSize(pBits); char* pBuffer = new char[ulBufferLen + 1]; memset(pBuffer, 0, ulBufferLen + 1); memcpy(pBuffer, pBits, ulBufferLen); GlobalUnlock(hOutGlobal); pOutStream->Release(); image = gfx::ImageFrom1xJPEGEncodedData((const unsigned char*)pBuffer, ulBufferLen); delete[]pBuffer; } } return image; }// png、gif之类的图片都会加载成功
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表