不只是可以显示png,jpg,bmp等等都可以,gif也行,不过只能显示单帧。

一种方法是用IImagingFactory 中的CreateImageFromFile

先看看msdn:

This method lets an application create a decoded image object from a file.

Syntax

HRESULT CreateImageFromFile(
const WCHAR* filename,
IImage**     image
);

Parameters

filename

[in] A WCHAR array containing the name of the source file.

image

[out] A pointer to the resulting IImage interface pointer.

Return Value

If successful, this method returns S_OK.

This method may return E_POINTER if it fails.

Remarks

When the decoded image object is created, it only keeps a reference to the external data source and does not immediately decode the image. The decoded image opens the file in read-only mode and allows shared-read access to it.

Be aware that decoded image objects are read-only. In particular, you cannot modify the image data. However, you can display it onto a destination graphics context or push its data into an image sink. For more information, see IImage.

Requirements

OS Versions: Windows CE 5.0 and later.

Header: Imaging.h.

Link Library: Imaging.

所以很简单了

  1. /************************************************************************************
  2. *
  3. *   函数名称        ShowPng
  4. *   函数介绍        显示png图片
  5. *   入口参数        const WCHAR *filename,  //文件路径
  6. *                           CRect *pRect,                    //显示区域
  7. *                           CDC *pDc,                        //dc
  8. *   出口参数        无
  9. *   返回  值          void
  10. *
  11. ***********************************************************************************/
  12. void ShowPng(const WCHAR *filename, CRect *pRect, CDC *pDc)
  13. {
  14. IImagingFactory *pImageFactory = NULL;
  15. IImage *pImage = NULL;
  16. HRESULT hrCreInstance = CoCreateInstance( CLSID_ImagingFactory, NULL,                   CLSCTX_INPROC_SERVER,IID_IImagingFactory, (void **)&pImageFactory);
  17. HRESULT hrLoadFile = pImageFactory->CreateImageFromFile(filename, &pImage);
  18. if (S_OK != hrCreInstance || S_OK != hrLoadFile)
  19. {
  20. AfxMessageBox(L"加载图片失败!!!");
  21. return;
  22. }
  23. pImage->Draw( pDc->GetSafeHdc(), pRect, NULL );
  24. pImage->Release();
  25. pImageFactory->Release();
  26. }

注意:

  1. #include <Imaging.h>

还有另外一种方法:

就是用SHLoadImageFile函数。

先看msdn:

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 Value

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.

When you no longer need the bitmap, call the DeleteObject function to delete it.

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.

  1. /************************************************************************************
  2. *
  3. *   函数名称        ShowPic
  4. *   函数介绍        显示png图片
  5. *   入口参数        const WCHAR *filename,  //文件路径
  6. *               CRect *pRect,           //显示区域
  7. *               CDC *pDc,       //dc
  8. *   出口参数        无
  9. *   返回  值       void
  10. *
  11. ***********************************************************************************/
  12. void ShowPic(const WCHAR *filename, CRect *pRect, CDC *pDc)
  13. {
  14. CDC dccom;
  15. dccom.CreateCompatibleDC(pDc);
  16. HBITMAP hbitmap = SHLoadImageFile(filename);
  17. CBitmap *bk,pp;
  18. bk = pp.FromHandle(hbitmap);
  19. BITMAP bitmap;
  20. bk->GetBitmap(&bitmap);
  21. CBitmap *pOldbmp = dccom.SelectObject(bk);
  22. pDc->StretchBlt(0,0,pRect->Width(),pRect->Height(),&dccom,0,0,bitmap.bmWidth,bitmap.bmHeight,SRCCOPY);
  23. }

Windows Mobile 上显示png,jpg,bmp等图片相关推荐

  1. 创建Windows Mobile上兼容性好的UI 程序

    看看上面这个Emulator的截图吧,有WM 2003se.5.0.6.0的,有pocket PC.smartphone.classic.professional的,有英文的,也有中文的,分辨率.DP ...

  2. java for mobil,Windows Mobile上的Java(ME)

    Does anyone have experience deploying Java ME apps to Windows Mobile? What are the high-level steps ...

  3. rss源_如何在Windows桌面上显示RSS源

    rss源 Recently we explained what RSS Feeds are and how you can benefit from them, and today we are ba ...

  4. STM32如何在LCD上显示单词、文字、图片等

    本文将介绍STM32F103R6如何在LCD12864上显示文字图片 注:本文中用到的字模软件,我放在了文章末尾,点击链接即可下载,是绿色版软件,解压即可使用! 点击下载LCD12864上显示文字图片 ...

  5. 转贴下windows mobile上常用的注册表优化选项

    在修改前请大家先备份好注册表!以防万一 一.提高系统运行速度     打开HKEY_LOCAL_MACHINE/System/StorageManager/FATFS查看值/EnableCache:将 ...

  6. 【转载】windows mobile 上隐藏和关闭X以及OK的处理

    [转自]http://blog.csdn.net/czbever 1.隐藏X:  在WM_CREATE里  SetWindowLong(hWnd,GWL_STYLE,WS_NONAVDONEBUTTO ...

  7. windows电脑上显示中文完好,新安装的办公系统上输入中文显示错误、无法显示中文

    问题描述:在自己电脑是所有地方都能正常显示中文字体,却在新下载的公司OA办公软件中输入中文简体字无法准确显示,当输入一个字体时不能显示,输入多个字却显示其他不对应的字. 解决方法: 打开设置,找到下面 ...

  8. 在Windows Mobile上运行J2SE/J2ME!!!!!

    本来来自http://blog.csdn.net/hellogv/ 有没有想过,在PC运行的J2SE程序可以在WINCE/PPC2003以上的系统运行? 现在外国的开源社区已经实现了做出来了这个WIN ...

  9. WEB在打印fr3报表上显示二维码和图片

    代码: #region 生成二维码DataRow dr = ReportData.Rows[0];var DEtEvl = dr["DEtEvl"].ToString() == & ...

最新文章

  1. 四人过桥问题c语言编程,SQL趣题:四人过桥的问题
  2. 无人驾驶:车道线检测,附代码
  3. 一维数组中的一些问题
  4. Guava新集合-Multiset
  5. 【Bugly 技术干货】Android开发必备知识:为什么说Kotlin值得一试
  6. oracle 9i乱码,oracle 9i sql*plus worksheet乱码问题
  7. 一位 90 后程序员的自述:如何从年薪 3W 到 30W
  8. 设计程序时,注意和外系统连携相关的处理
  9. Pr 入门教程,如何处理图片文件?
  10. 解决安卓全屏问题:关键在于如何隐藏状态栏
  11. networkx 有向图强连通_基于networkx分析Louvain算法的社团网络划分
  12. 微信小程序视频基本操作
  13. 计算机复制教程,ghost复制c盘到另一个硬盘方法
  14. 台式计算机蓝牙在哪,台式电脑蓝牙在哪里打开(台式电脑连接蓝牙教程分享)...
  15. SpringCloud自定义负载均衡策略--LoadBalancer
  16. JSON必备工具之Json Viewer
  17. CE进阶操作--自带小游戏TutorialGame的修改方法
  18. 微软洗牌低代码开发市场,引发软件产业生态变局
  19. 破解 WiFi,获取 WiFi 密码
  20. GX Works3 (四):FX5U作为服务端的以太网MC协议梯形图通信编程

热门文章

  1. Python 爬取公众号文章链接并生成html
  2. Linux 符号系列
  3. python 并发之 多线程处理IO操作
  4. 中国电子学会2022年09月份青少年软件编程Scratch图形化等级考试试卷二级真题(含答案)
  5. 紫光云三个月上线,背后是一个怎样的布局?
  6. 腾讯云cos图片迁移
  7. 什么是栈溢出和堆溢出
  8. flask POST请求,数据入库,文件上传,一文看懂,3天掌握Flask开发项目系列博客之三
  9. matlab rle,Matlab下RLE算法的简单实现
  10. 最近开发的一款支持主流阅片功能的阅片器