Windows Mobile读取位图资源的像素数据问题
来源:互联网 发布:网络的正面影响有哪些 编辑:程序博客网 时间:2024/05/22 20:28
平台:
windows mobile6.5(应该也适用Windows CE),VS2008
问题:
位图资源中已经有个叫IDB_BITMAP1的位图,想获得它的像素数据(即unsigned char类型的一块内存数据),
在PC上的方法:
m_bitmap.LoadBitmap(IDB_BITMAP1); // 加载位图资源, m_bitmap为CBitmap类型
BITMAP bmStruct;
m_bitmap.GetBitmap(&bmStruct);
// bmStruct.bmWidth和bmStruct.bmHeight 为位图资源的尺寸
// bmStruct.bmBits 为像素数据块
但是:在windows mobile平台上可以获得bmStruct.bmWidth和bmStruct.bmHeight 的正确值,但是bmStruct.bmBits始终为NULL!
解决方法:使用FindResource(),LoadResource()等API
m_pBoxData = NULL; // unsigned char*unsigned char *dataBuf = NULL; // total memory block, including image headerDWORD dwBufSize = 0; // size of total memory blockHRSRC hrc = FindResource(AfxGetResourceHandle(),MAKEINTRESOURCE(IDB_BITMAP3),RT_BITMAP);HGLOBAL hGlobal = LoadResource(NULL,hrc);dwBufSize = ::SizeofResource(NULL,hrc); // BITMAP(imagedata+inforhead(40bytes,fixed))dataBuf = (PBYTE)::LockResource(hGlobal); // imagedata pointerm_pBoxData = new unsigned char[dwBufSize-40];// -40bytes(imageheader)memcpy(m_pBoxData, dataBuf, sizeof(unsigned char)*(dwBufSize-40)); // copyFreeResource(hGlobal);BITMAP tmpBM;m_bitmapBox.GetBitmap(&tmpBM);// obtain the width and height of the bmp imagem_bmpImageWidth = tmpBM.bmWidth;m_bmpImageHeight = tmpBM.bmHeight;
参考:http://hi.baidu.com/gengyit/blog/item/5785a5fe8181f4f1fc037f91.html#0
- Windows Mobile读取位图资源的像素数据问题
- 按扇区读取Windows Mobile的数据
- 按扇区读取Windows Mobile的数据
- windows mobile下的位图
- 使用Excel的VBA来读取和修改bmp位图像素数据
- Windows Mobile载入位图的方法
- Windows Mobile载入位图的方法
- Windows Mobile载入位图的方法
- FindFirstStore函数 按扇区读取Windows Mobile的数据
- FindFirstStore函数 按扇区读取Windows Mobile的数据
- opencv中读取图像像素数据的问题
- 位图像素的颜色
- C++读取BMP位图数据的方法
- OpenCV-CvMat的像素数据读取方法
- 像素数据的读取和拷贝
- Windows Mobile下,WMPLib资源的释放
- c语言实现读取位图像素信息
- Windows Mobile 快捷方式的读取和创建
- 坚持
- 次方计算
- WPF 自带控件 总结之二
- 西典军校的经典法则
- 一些.Net面试题 (BS 方向)
- Windows Mobile读取位图资源的像素数据问题
- 智猪博弈理论简介
- 走迷宫问题(求出所有的可能的解)
- Java中获取系统当前时间
- Android 下log的使用总结
- gst-launch
- System.Timers.Timer的使用
- 设计模式——责任链模式(Chain Of Responsibility)
- 嵌入式Linux驱动工程师笔试题(转载)