首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Windows Mobile >

WinCE怎么加载位图

2012-02-12 
WinCE如何加载位图满足如下条件:1. WinCE5.02. 从文件读取一个RGB24bit的bitmap3. 读取的数据转化为RGB16b

WinCE如何加载位图
满足如下条件:
1. WinCE5.0
2. 从文件读取一个RGB24bit的bitmap
3. 读取的数据转化为RGB16bit,即:RGB565的bitmap
4. 将数据加载到屏幕(或者DDraw的后台缓存中)

Thanks in advanced!

[解决办法]
我说一个流程啊 可能有点拗口

1. SHLoadBitmap 拿到一个HBitmap的句柄定义问HB1
2. CreateDIBSection一个565的BITMAPINFO 注意这里面是没有data的定义为HB2
3. 创建MemDC1, MemDC2.为compatibleDC 
4. 把HB1 SelectObject 给MemDC1, HB2 SelectObject 给MemDC2
5. 再把MemDC1 BitBlt到MemDC2

到这里你的HB2就是你需要的HBItmap的句柄了,CreateDIBSection时候的buffer里面就是你需要的565的数据了,可能有些繁琐 呵呵




[解决办法]
你可以把图片复制到当前的项目中,然后通过
Image im=new Bitmap(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("命名空间.图片名称)); 将图片加载到对象im中,然后调用im就可以操作这个图片了
[解决办法]
用这个函数,直接可以用24位的数据,具体参数看msdn和Google一下
WINGDIAPI BOOL WINAPI StretchDIBits(
HDC hdc,
int XDest,
int YDest,
int nDestWidth,
int nDestHeight,
int XSrc,
int YSrc,
int nSrcWidth,
int nSrcHeight,
CONST VOID* lpBits,
CONST BITMAPINFO* lpBitsInfo,
UINT iUsage,
DWORD dwRop
);
Parameters
hdc 
[in] Handle to the destination device context. 
XDest 
[in] Integer that specifies the x-coordinate, in logical units, of the upper left corner of the destination rectangle. 
YDest 
[in] Integer that specifies the y-coordinate, in logical units, of the upper left corner of the destination rectangle. 
nDestWidth 
[in] Integer that specifies the width, in logical units, of the destination rectangle. 
nDestHeight 
[in] Integer that specifies the height, in logical units, of the destination rectangle. 
XSrc 
[in] Integer that specifies the x-coordinate, in pixels, of the origin of the source rectangle in the DIB. 
YSrc 
[in] Integer that specifies the y-coordinate, in pixels, of the origin of the source rectangle in the DIB. 
nSrcWidth 
[in] Integer that specifies the width, in pixels, of the source rectangle in the DIB. 
nSrcHeight 
[in] Integer that specifies the height, in pixels, of the source rectangle in the DIB. 
lpBits 
[in] Pointer to the DIB bits, which are stored as an array of bytes. 
lpBitsInfo 
[in] Pointer to a BITMAPINFO structure that contains information about the DIB. 
iUsage 
[in] Unsigned integer that specifies whether you provided a value for the bmiColors member of the BITMAPINFO structure, and, if so, whether bmiColors contains explicit red, green, blue (RGB) values or indexes. 
The following table shows the possible values. 

Value Description 
DIB_PAL_COLORS The array contains 16-bit indexes into the logical palette of the source device context. 
DIB_RGB_COLORS The color table contains literal red, green, and blue values. 

dwRop 
[in] DWORD that specifies how to combine the source pixels, the current brush of the destination device context, and the destination pixels to form the new image.

热点排行