WinCE平台上JPEG图片的显示

关于WinCE平台上JPEG图片的显示, 应该使用以下函数:

This function reads an image file, decompresses it, and returns a handle to a bitmap in memory.

Syntax
HBITMAP SHLoadImageFile (
  LPCTSTR pszFileName
);
Parameters
pszFileName
[in] The name of the image file to be loaded.
Return Values

A handle to a bitmap if successful, NULL otherwise.

Remarks

This function converts files of several types, including GIF (Graphics Interchange Format), PNG (Portable Network Graphics), JPG (Joint Photographic Experts Group), ICO (icon), and BMP (bitmap) file formats. Other image file types may be supported if the correct decoder is installed.

Requirements

Pocket PC: Windows Mobile 2003 and later.
OS Versions: Windows CE .NET 4.0 and later.
Header: Declared in Aygshell.h.
Library: Use Aygshell.lib.

 

 

首先将该JPG 图片放到和.rc文件同一级的目录下,修改.rc文件:
添加代码如下:IDR_IMAGE          GIF          "x.JPG"
然后在“resource.h”中添加: #define IDR_IMAGE  xxx
在WM_PAINT下添加:
        GetClientRect (hWnd, &rect);
        hdc = BeginPaint (hWnd, &ps);
hBitmap=SHLoadImageResource(g_hInst,
IDR_IMAGE);
  GetObject(hBitmap, sizeof(bm), &bm);
hMemDC = CreateCompatibleDC(hdc);
cy = bm.bmHeight;
if (hMemDC != NULL)
{
hOldBitmap = (HBITMAP)SelectObject(hMemDC, hBitmap);
BitBlt(hdc,        (rect.right - bm.bmWidth) / 2,
(rect.bottom - cy) / 2, bm.bmWidth, bm.bmHeight,
hMemDC, 0, 0, SRCCOPY);
SelectObject(hMemDC, hOldBitmap);
DeleteDC(hMemDC);
}
        EndPaint (hWnd, &ps);
这样就OK了!

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值