WM下的GDI+(续)

上篇文章标题有误,应该是WM下的

上次我试验了我的劳动成果,证明是不行的。不过这里有人给出一个可以实用的版本。我来说下我的试用成果。

一、安装

下载后,将文件复制到相应的文件夹中,inlcude文件我是到Windows Mobile 6 SDK\PocketPC\Include\Armv4i\GDI+(我只试用了WM^下)下,这样出问题好处理。lib文件到\Windows Mobile 6 SDK\PocketPC\Lib\Armv4i下。在引用路径也要加上这些路径。

二、准备

首先在头文件中加入

include <gdiplus.h>
using   namespace   Gdiplus; 

#pragma   comment   (lib,   "LibGDIPlus.lib")

在Oncreat事件中,调用

GdiplusStartupInput gdiplusStartupInput;
 ULONG_PTR           gdiplusToken;
 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

进行初始化。在Ondestory事件中调用

GdiplusShutdown(gdiplusToken);

进行结束。

可以将gdiplusToken设为公用变量,这样可以不出问题。但初始化不能在DLL中进行,不知道是为什么 。

三、使用

wince下的GDI+有好多功能没有实现:

  • No support to load image file directly from path
    Use IStream interface to load file data, use the stream interface version to create bitmap. Same goes for resource.
  • Windows Mobile doesn't support the following features:
    GDI Path (GDI path functions are not exported)
    Enhanced Meta file

前一个我认为可这样解决一是使用ISTREAM但比较复杂,二是使用GDI

m_bt=new Bitmap(::SHLoadImageFile(_T("\\Program Files\\aaa.png")),0);但支持范围有限。

后面的我没试过。

在试用中还发现些问题,比较重要的Drawimgae有18函数只有下面6个实现了

         Graphics::DrawImage(Image*,RectF&)
         Graphics::DrawImage(Image*,INT,INT,INT,INT)
 Graphics::DrawImage(Image*,PointF*,INT,REAL,REAL,REAL,REAL,Unit,ImageAttributes*,DrawImageAbort,VOID*)
        Graphics::DrawImage(Image*,REAL,REAL,REAL,REAL)
        Graphics::DrawImage(Image*,Rect&)   Graphics::DrawImage(Image*,RectF&,REAL,REAL,REAL,REAL,Unit,ImageAttributes*,DrawImageAbort,VOID*)
这两个干脆没有原型

Graphics::DrawImage(Image*,RectF&,RectF&,Unit,ImageAttributes*)
Graphics::DrawImage(Image*,RectF*,Matrix*,Effect*,ImageAttributes*,Unit*)
不过主要功能还是能实现了。还有就是RotateTransform也不支持,这个就比较苦恼了。

posted on 2009-10-17 16:32  zcmky  阅读(1427)  评论(1编辑  收藏  举报

导航