WinCE平台上JPEG图片的显示

来源:互联网 发布:阿里云域名购买流程 编辑:程序博客网 时间:2024/04/28 22:05
关于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了!

 

原创粉丝点击