﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-一针见血-文章分类-Brew</title><link>http://www.cppblog.com/gtwdaizi/category/8365.html</link><description /><language>zh-cn</language><lastBuildDate>Fri, 31 Oct 2008 06:31:08 GMT</lastBuildDate><pubDate>Fri, 31 Oct 2008 06:31:08 GMT</pubDate><ttl>60</ttl><item><title>[BREW]brew中的文件系统路径表示</title><link>http://www.cppblog.com/gtwdaizi/articles/63213.html</link><dc:creator>郭天文</dc:creator><author>郭天文</author><pubDate>Sat, 04 Oct 2008 02:25:00 GMT</pubDate><guid>http://www.cppblog.com/gtwdaizi/articles/63213.html</guid><wfw:comment>http://www.cppblog.com/gtwdaizi/comments/63213.html</wfw:comment><comments>http://www.cppblog.com/gtwdaizi/articles/63213.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/gtwdaizi/comments/commentRss/63213.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/gtwdaizi/services/trackbacks/63213.html</trackback:ping><description><![CDATA[&nbsp; "fs:/" (AEEFS_ROOT_DIR): the root of the BREW file namespace.&nbsp; Prefacing <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; a path with this string tells BREW to interpret the filename <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; according to the new namespace rules. <br>&nbsp; "fs:/~/" (AEEFS_HOME_DIR): this is a shortcut that denotes the <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currently running application's directory.&nbsp; It is mapped <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; to "fs:/mod/ &lt;modid&gt;" where &lt;modid&gt; is the module ID of <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; the currently running application. <br>&nbsp; "fs:/sys/" (AEEFS_SYS_DIR): this is the location of BREW's "system" <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; files.&nbsp; Access to this directory is restricted,&nbsp; See <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IFILEMGR_CheckPathAccess() for more information. <br>&nbsp; "fs:/mod/" (AEEFS_MOD_DIR): the location of all the module directories <br>&nbsp; "fs:/mif/" (AEEFS_MIF_DIR): the location of all of BREW's MIF files. <br>&nbsp; "fs:/shared/" (AEEFS_SHARED_DIR): the new name for "Shared".&nbsp; This <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name can be used to share files with other applications <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; using case-sensitive names <br>&nbsp; "fs:/address/" (AEEFS_ADDRESS_DIR): the location of the address book <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; directory.&nbsp; This directory is only present when the <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; address book for the device is implemented using the default <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BREW address book implementation.&nbsp; It is mapped mostly for <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; backwards compatibility with the old BREW file <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; namespace AEE_ADDRBOOK_DIR ("addrbk") in AEE.h <br>&nbsp; "fs:/ringers/" (AEEFS_RINGERS_DIR): the location of the device's ringer <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; directory.&nbsp; An application must have PL_RINGER_WRITE (Write <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Access to Ringer Directory) to access files in this <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; directory. <br>&nbsp; "fs:/card0/" (AEEFS_CARD0_DIR): New for BREW 3.1, if a device supports <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; a removable media card format, this path maps to the first <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; instance of such a device.&nbsp; An application must list <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AEECLSID_CARD0_ACCESS in its MIF in the "Dependencies" <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; section to access files in this directory. <br>&nbsp; "fs:/~ &lt;clsid&gt;/": New for BREW 3.1, an application may access files <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; in another application's directory.&nbsp; &lt;clsid&gt; must be a <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; valid class id of an application or extension.&nbsp; These <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; paths map to "fs:/mod/ &lt;modid&gt;" where &lt;modid&gt; is the <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; module id of the module that exports &lt;clsid&gt;.&nbsp; The target <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; module must export this path via a module ACL.&nbsp; See <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IFILEMGR_CheckPathAccess() for more information. 
<img src ="http://www.cppblog.com/gtwdaizi/aggbug/63213.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/gtwdaizi/" target="_blank">郭天文</a> 2008-10-04 10:25 <a href="http://www.cppblog.com/gtwdaizi/articles/63213.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[BREW]BREW中 - 显示和图像</title><link>http://www.cppblog.com/gtwdaizi/articles/62862.html</link><dc:creator>郭天文</dc:creator><author>郭天文</author><pubDate>Sat, 27 Sep 2008 01:46:00 GMT</pubDate><guid>http://www.cppblog.com/gtwdaizi/articles/62862.html</guid><wfw:comment>http://www.cppblog.com/gtwdaizi/comments/62862.html</wfw:comment><comments>http://www.cppblog.com/gtwdaizi/articles/62862.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/gtwdaizi/comments/commentRss/62862.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/gtwdaizi/services/trackbacks/62862.html</trackback:ping><description><![CDATA[<span style="COLOR: red">a. BREW 支持哪些图像格式？</span> <br>适用版本： 1.0, 1.1, 2.0 <br>BREW 支持颜色深度达到运行设备上提供的值的任何 BMP 文件。 BREW 目前尚不支持 GIF 和 JPEG 图像。 有些设备可以支持 GIF 和 JPEG 图像，请参阅设备数据表来查看 OEM 是否提供了支持以上格式或其它格式图像的扩展。 BREW SDK&amp;reg; 1.1 以上版本都支持 PNG 格式和 BREW Compressed Image (BCI) 格式。 SDK 2.0 以上版本都支持 IDIB。 使用 IDIB 将免除您调用 CONVERTBMP 的工作，从而提高屏幕更新速度。 BREW SDK&amp;reg; 2.1 以上版本将支持 WBMP 格式。 <br><br>在 BREW SDK&amp;reg; 1.0 中，模拟器只能模拟 1 位、4 位和 8 位颜色深度的 BMP。 SDK 1.1 增加了对 2 位颜色深度 BMP 的模拟器支持；2.0 SDK 增加了对 16 位颜色深度 BMP 图像的模拟器支持。 <br><br><span style="COLOR: red">b. 如何生成 2 位图像？ <br></span>适用版本： 1.0, 1.1, 2.0 <br>2.0 SDK 中包含的 2 Bit Tool可以进行 2 位位图和 4 位位图之间的转换。 要构建采用灰度显示的手持设备使用的 2 位位图，可以使用 MS Paint 从调色板中选择白色、黑色、淡灰和深灰条目（通常为第一行和第二行的前两种颜色）来构建位图。 并将其保存为 16 色图像，然后使用 2Bit Tool 将其转换为 2 位位图。 <br><br><span style="COLOR: red">c. 彩色和单色电话上的透明色是什么？</span> <br>适用版本： 1.0, 1.1, 2.0 <br>BREW 1.x 中紫色为彩色设备的透明色，白色是单色和 4 级灰度设备上的透明色。 <br><br>BREW 2.0 以上版本中，可以通过 IBITMAP_SetTransparencyColor 更改透明色。 CONVERTBMP 可以将透明色初始化为兼容旧版本 BREW 的透明色（即紫色和白色）。 但通过其它方式获得的位图图像则没有固定的透明色。 <br><br><span style="COLOR: red">d. 如何使用内存中的位图创建 IIMAGE 对象？</span><br>适用版本： 1.0, 1.1, 2.0 <br>使用 ISHELL 接口 ISHELL_LoadResImage（用于资源）和 ISHELL_LoadImage（用于文件）完成作为资源或从文件中加载位图。 但是，有时可能必须从内存中初始化 IIMAGE 对象 - 例如显示前修改位图的内容时，或者不先将数据缓存到文件而通过套接字连接检索图像时。 <br><br>在必须用内存中的位图初始化 IIMAGE 对象的情况下，应该使用 IIMAGE 接口 IIMAGE_SetStream。 下面的代码示例说明了这种技术。它通过调用 ISHELL_GetHandler 获得 BMP 图像处理程序的 Class ID，然后创建一个 MemAStream 对象并将其用作内存中位图的流。 注意：本例中的图像格式是 Windows BMP，&#8220;pMe-&gt;pBmpData&#8221;指向 Windows 文件格式 BMP 的开始 (BITMAPFILEHEADER)。 <br><br>代码示例： <br>AEECLSID cls;<br>IImage *pIImage = NULL;<br>IMemAStream *pMemStream = NULL;<br><br>// 决定 BMP处理程序函数的类 ID，然后<br>// 创建此 BREW 类的实例<br>cls = ISHELL_GetHandler(pMe-&gt;a.m_pIShell, HTYPE_VIEWER, "image/bmp");<br><br>if (cls) {<br>ISHELL_CreateInstance(pMe-&gt;a.m_pIShell, cls, (void **)(&amp;pIImage));<br>}<br><br>if (pMe-&gt;pBmpData) {<br>ISHELL_CreateInstance(pMe-&gt;a.m_pIShell, AEECLSID_MEMASTREAM, (void **)(&amp;pMemStream));<br>if (pMemStream) {<br>//创建 MEMSTREAM 后将其作为内存中的位图的流。<br>IMEMASTREAM_Set(pMemStream, pMe-&gt;pBmpData, sizeof(pMe-&gt;pBmpData), 0, 0);<br>IIMAGE_SetStream(pIImage, (IAStream*)pMemStream);<br><br>// 现在以正常方式使用您的 IIMAGE 方法<br>IIMAGE_Draw(pIImage, ..., ...);<br>IDISPLAY_UpdateEx(pMe-&gt;a.m_pIDisplay, TRUE);<br>}<br>} <br><br><span style="COLOR: red">e. 如何从文件或资源文件加载图像？</span> <br>通过使用 ISHELL 接口 ISHELL_LoadResImage（用于资源）或 ISHELL_LoadImage（用于文件），后跟 IIMAGE_Draw，很容易从文件或资源中加载和绘制图像。本文演示了使用 ISHELL 和 IIMAGE 接口加载和显示位图所需的基本步骤。 <br><br>从资源中显示图像的步骤： <br>1. 创建位图。<br>2. 将其添加到资源编辑器中。<br>3. 在资源编辑器中编译 .bar 和 .h 文件。 <br>4. 将 .h 文件添加到您的项目中。<br>5. 使用 ISHELL_LoadResImage 加载图像。<br>6. 如果加载操作返回非空值，这说明加载操作已启动，指向图像的指针已返<br>&nbsp; &nbsp; 回。这并不表示图像加载已完成。要了解图像操作的完成时间，您需要使<br>&nbsp; &nbsp; 用 IIMAGE_Notify() 回调。 <br>7. 图像加载完成时，就会触发回调。<br>8. 在回调过程中，使用 IIMAGE_Draw() 显示图像。<br>9. 使用 IDISPLAY_Update() 更新屏幕。<br>10. 释放 IImage 指针。<br><br>从文件中显示图像的步骤： <br>1. 使用 ISHELL_LoadImage 从文件中加载图像。<br>2. 如果加载操作返回非空值，这说明加载操作已启动，指向图像的指针已返<br>&nbsp; &nbsp; 回。这并不表示图像加载已完成。要了解图像操作的完成时间，您需要使<br>&nbsp; &nbsp; 用 IIMAGE_Notify() 回调。<br>3. 图像加载完成时，就会触发回调。<br>4. 在回调过程中，使用 IIMAGE_Draw() 显示图像。<br>5. 使用 IDISPLAY_Update() 更新屏幕。<br>6. 释放 IImage 指针。<br><br>代码示例：<br>typedef struct mystruct<br>{<br>&nbsp; &nbsp; AEEApplet a;<br>&nbsp; &nbsp; IImage *m_pImage;<br>&nbsp; &nbsp; ......<br>}MyData;<br><br>enum ResType<br>{<br>&nbsp; &nbsp; LOAD_RES_FROM_FILE,<br>&nbsp; &nbsp; LOAD_RES_FROM_RES<br>};<br><br>#define MY_RES_FILE "myres.bar"<br>#define MY_IMAGE_FILE "myimg.bmp"<br><br>// Load and display a bitmap from a resource and file<br>int MyDisplayResImage(MyData *pMe, ResType rType)<br>{<br>&nbsp; &nbsp; AEEDeviceInfo dm;<br><br>&nbsp; &nbsp; if (!pMe)<br>&nbsp; &nbsp; Return EFAILED;<br><br>&nbsp; &nbsp; if (rType == LOAD_RES_FROM_RES)<br>&nbsp; &nbsp; {<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;// Load image from Resources<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;pMe-&gt;m_pImage = ISHELL_LoadResImage (<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;pMe-&gt;a.m_pIShell,<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;MY_RES_FILE,<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;IDB_MY_COLOR_BITMAP);<br>&nbsp; &nbsp; }<br>&nbsp; &nbsp; else // LOAD_RES_FROM_FILE<br>&nbsp; &nbsp; {<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;pMe-&gt;m_pImage = ISHELL_LoadImage(pMe-&gt;a.m_pIShell,<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;MY_IMAGE_FILE); <br>&nbsp; &nbsp; }<br><br>&nbsp; &nbsp; if (pMe-&gt;m_pImage) {<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;IIMAGE_Notify(pMe-&gt;m_pImage, DrawRoutineCB,<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;(void *)pMe);<br>&nbsp; &nbsp; }<br>&nbsp; &nbsp; else<br>&nbsp; &nbsp; {<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;return EFAILED; // Failed to load image <br>&nbsp; &nbsp; }<br>&nbsp; &nbsp; return SUCCESS;<br>}<br><br>// Notify Callback<br>void DrawRoutineCB(void *pUser, IImage *pImage,<br>AEEImageInfo *pi, int nErr)<br>{<br>&nbsp; &nbsp; MyData *pMe = (MyData *)pUser;<br><br>&nbsp; &nbsp; if( !pMe || !(pMe-&gt;m_pImage)<br>&nbsp; &nbsp; return; // image pointer is NULL<br><br>&nbsp; &nbsp; if (nErr == AEE_SUCCESS)<br>&nbsp; &nbsp; {<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;// Draw image at 0,0 coordinates<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;IIMAGE_Draw(pMe-&gt;m_pImage, 0, 0); <br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;// Update the screen<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;IDISPLAY_Update(pMe-&gt;a.m_pIDisplay); <br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;// Free the IIMAGE object<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;IIMAGE_Release(pMe-&gt;m_pImage ); <br>&nbsp; &nbsp; }<br>}<br><br>注意：回调（通过 IIMAGE_Notify() 进行）之前，不得释放 IImage 接口。在应用程序需要在回调文件之前释放接口的情况下，建议改设会表明应该在回调（上例中的 DrawRoutineCB）中释放接口的布尔标记。<br><br><span style="COLOR: red">f. 我用 ISHELL_LoadResImage() 加载图像并调用 IIMAGE_Draw() 后为什么看不到屏幕图像？</span><br>加载图像为异步操作。ISHELL_ LoadResImage() 操作返回时，图像未完全加载，可能无法成功绘制。<br><br>返回图像加载的非空值时，说明加载操作已启动，指向图像的指针已返回。这并不表示加载操作已完成。要了解加载操作的完成时间，用户应使用 IIMAGE_Notify()回调。该回调会在图像成功加载并准备绘制到屏幕上时触发。此时，用户应使用 IIMAGE_Draw() 在屏幕上显示图像。<br><br>从文件或资源正确加载和绘制图像的示例如下：<br><br>从资源中显示图像的步骤：<br>1. 创建位图。<br>2. 将其添加到资源编辑器中。<br>3. 在资源编辑器中编译 .bar 和 .h 文件。<br>4. 将 .h 文件添加到您的项目中。<br>5. 使用 ISHELL_LoadResImage 加载图像。<br>6. 如果加载操作返回非空值，这说明加载操作已启动，指向图像的指针已返<br>&nbsp; &nbsp; 回。这并不表示图像加载已完成。要了解图像操作的完成时间，您需要使<br>&nbsp; &nbsp; 用 IIMAGE_Notify() 回调。<br>7. 图像加载完成时，就会触发回调。<br>8. 在回调过程中，使用 IIMAGE_ Draw() 显示图像。<br>9. 使用 IDISPLAY_Update() 更新屏幕。<br>10. 释放 IImage 指针。<br><br>从文件中显示图像的步骤：<br>1. 使用 ISHELL_LoadImage 从文件中加载图像。<br>2. 如果加载操作返回非空值，这说明加载操作已启动，指向图像的指针已返<br>&nbsp; &nbsp; 回。这并不表示图像加载已完成。要了解图像操作的完成时间，您需要使<br>&nbsp; &nbsp; 用 IIMAGE_Notify() 回调。 <br>3. 图像加载完成时，就会触发回调。<br>4. 在回调过程中，使用 IIMAGE_ Draw() 显示图像。<br>5. 使用 IDISPLAY_Update() 更新屏幕。<br>6. 释放 IImage 指针。<br><br>代码示例：<br>typedef struct mystruct<br>{<br>&nbsp; &nbsp; AEEApplet a;<br>&nbsp; &nbsp; IImage *m_pImage;<br>&nbsp; &nbsp; ......<br>}MyData;<br><br>enum ResType<br>{<br>&nbsp; &nbsp; LOAD_RES_FROM_FILE,<br>&nbsp; &nbsp; LOAD_RES_FROM_RES<br>};<br><br>#define MY_RES_FILE "myres.bar"<br>#define MY_IMAGE_FILE "myimg.bmp"<br><br>// Load and display a bitmap from a resource and file<br>int MyDisplayResImage(MyData *pMe, ResType rType)<br>{<br>&nbsp; &nbsp; AEEDeviceInfo dm;<br><br>&nbsp; &nbsp; if (!pMe)<br>&nbsp; &nbsp; Return EFAILED;<br><br>&nbsp; &nbsp; if (rType == LOAD_RES_FROM_RES)<br>&nbsp; &nbsp; {<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;// Load image from Resources<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;pMe-&gt;m_pImage = ISHELL_LoadResImage (<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;pMe-&gt;a.m_pIShell,<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;MY_RES_FILE,<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;IDB_MY_COLOR_BITMAP);<br>&nbsp; &nbsp; }<br>&nbsp; &nbsp; else // LOAD_RES_FROM_FILE<br>&nbsp; &nbsp; {<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;pMe-&gt;m_pImage = ISHELL_LoadImage(pMe-&gt;a.m_pIShell,<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;MY_IMAGE_FILE); <br>&nbsp; &nbsp; }<br><br>&nbsp; &nbsp; if (pMe-&gt;m_pImage) {<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;IIMAGE_Notify(pMe-&gt;m_pImage, DrawRoutineCB,<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;(void *)pMe);<br>&nbsp; &nbsp; }<br>&nbsp; &nbsp; else<br>&nbsp; &nbsp; {<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;return EFAILED; // Failed to load image <br>&nbsp; &nbsp; }<br>&nbsp; &nbsp; return SUCCESS;<br>}<br><br>// Notify Callback<br>void DrawRoutineCB(void *pUser, IImage *pImage,<br>AEEImageInfo *pi, int nErr)<br>{<br>&nbsp; &nbsp; MyData *pMe = (MyData *)pUser;<br><br>&nbsp; &nbsp; if( !pMe || !(pMe-&gt;m_pImage)<br>&nbsp; &nbsp; return; // image pointer is NULL<br><br>&nbsp; &nbsp; if (nErr == AEE_SUCCESS)<br>&nbsp; &nbsp; {<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;// Draw image at 0,0 coordinates<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;IIMAGE_Draw(pMe-&gt;m_pImage, 0, 0); <br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;// Update the screen<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;IDISPLAY_Update(pMe-&gt;a.m_pIDisplay); <br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;// Free the IIMAGE object<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;IIMAGE_Release(pMe-&gt;m_pImage ); <br>&nbsp; &nbsp; }<br>}<br><br>注意：回调（通过 IIMAGE_Notify() 进行）之前，不得释放 IImage 接口。在应用程序需要在回调文件之前释放接口的情况下，建议改设会表明应该在回调（上例中的 DrawRoutineCB）中释放接口的布尔标记。 <br><br><span style="COLOR: red">g. BREW 是否支持动画？</span> <br>适用版本： 1.0, 1.1, 2.0 <br>BREW SDK&amp;reg; 版本 1.0 支持动画 BMP。 这是通过并列放置所有帧并使用带 IPARM-CXFRAME 标记的 IIMAGE_SetParm 指定每帧的宽度实现的。 请参阅 Examples 目录中的 IIMAGE 示例。 <br><br>BREW SDK&amp;reg; 版本 1.1 增加了对 BREW Compressed Image (BCI) 动画的支持。 BCI 文件包含一个或多个压缩的小图像，每个图像都有一个以毫秒指定的持续时间。 持续时间表示每一幅图像被该系列下一幅图像取代之前可显示的时间。 您可以使用 BREW SDK&amp;reg; 版本 1.1 随附的 BCI 编辑工具来创建 BCI 文件。 有关详细信息，请参阅 SDK 随附的&#8220;使用 BREW Compressed Image 编辑工具&#8221;文档。 <br><br>BREW 当前不支持 PNG 和 MNG 格式的动画。 <br><br><span style="COLOR: red">h. 为什么一段时间后所有动画都会变慢？</span> <br>适用版本： 1.0, 1.1, 2.0 <br>大多数 OEM 都使用了睡眠计时器。 它控制设备在何时进入睡眠状态。 如果在 OEM 指定的时间段内无按键活动，手持设备将进入睡眠状态。 设备处于睡眠状态时帧速率将大大降低。 按下任意键将唤醒设备并恢复到以前的帧速率。 <br><br>在 BREW 2.0 中，应用程序可选择是否要进入睡眠状态。 如果在应用程序收到 EVT_APP_NO_SLEEP 事件时返回 TRUE，应用程序将不会进入睡眠状态。 例如： <br><br>case EVT_APP_NO_SLEEP:<br>//不要睡眠 <br>return TRUE; <br><br><span style="COLOR: red">i. 是否可以获取/操纵设备的调色板信息？</span> <br>适用版本： 1.0, 1.1, 2.0 <br>不可以。调色板由生产商进行硬编码，随设备不同而有异。 <br><br><span style="COLOR: red">j. 是否可以直接修改显示缓冲区？</span> <br>适用版本： 1.0, 1.1, 2.0 <br>BREW 1.x 无法访问这些缓冲区，而且显示数据使用生产商的专有格式存储。 <br>从 BREW 2.0 开始，如果位图的像素布局兼容 BREW 设备无关位图规格，则这些位图会支持 IDIB 接口。 也可以通过 IDIB 结构的 pBmp 成员访问像素缓冲区。 要确定位图是否支持 IDIB 以及要获取 IDIB 指针，可以使用 Class ID 为 AEECLSID_DIB 的 IBITMAP_QueryInterface 函数。 <br><br><span style="COLOR: red">k. 是否可以进行后台渲染？</span> <br>适用版本： 1.0, 1.1, 2.0 <br>可以使用 IDISPLAY_Set/GetDestination 或 IGRAPHICS_Set/GetDestination 进行后台渲染。 BREW 1.2 以上版本将提供这些函数。 <br><br>不提供 1.2 BREW SDK&amp;reg;。 要使用 BREW 1.2 功能，可以使用 2.0 SDK 开发面向 BREW 1.2 的应用程序。 您应该注意不要使用 1.2 版本中不支持的 2.0 版本的功能。 此功能列表编写在 FAQ 文档目标设备安装了 BREW SDK&amp;reg; 1.2，但我找不到 BREW 1.2 SDK。 我应该使用什么 SDK 开发 BREW 应用程序？中。 <br><br>虽然文档中含有 IGRAPHICS_EnableDoubleBuffer API，但它不受任何 BREW 版本的支持。 <br><br><span style="COLOR: red">l. 如何绘制特定颜色的线段？</span> <br>适用版本： 1.0, 1.1, 2.0 <br>IDISPLAY_DrawHLine() 和 IDISPLAY_DrawVLine() 始终绘制黑色线段。 因此，将 CLR_USER_LINE 设置为所需颜色，然后调用 IDISPLAY_DrawHLine() 或 IDISPLAY_DrawVLine() 会变无效。 <br><br>这两个 IDISPLAY 宏的定义如下。 要绘制除黑色外的颜色的线段，请使用宏定义中所含的代码并更改为所需填充颜色。 <br><br>#define IDISPLAY_DrawHLine(p,x,y,len) \<br>{AEERect rc;SETAEERECT(&amp;rc,(x),(y),(len),1); IDISPLAY_FillRect((p),&amp;rc, RGB_BLACK);} <br><br>#define IDISPLAY_DrawVLine(p,x,y,len) \<br>{AEERect rc;SETAEERECT(&amp;rc,(x),(y),1,(len)); IDISPLAY_FillRect((p),&amp;rc, RGB_BLACK);} <br><br><span style="COLOR: red">m. 如何确定在电话上显示应用程序名的字符限制？</span> <br>适用版本： 1.0, 1.1, 2.0 <br>不同的电话具有不同的显示特性，因此对此问题没有唯一答案。 您可以通过比较应用程序名的宽度和显示宽度来确定应用程序名是否适合电话显示。 <br><br>使用 IDISPLAY_MeasureText() 确定应用程序名字符串的像素宽度。 使用 ISHELL_GetDeviceInfo() 确定屏幕的像素宽度。 <br><br><span style="COLOR: red">n. 如何将图像保存到电话的墙纸目录？</span> <br>适用版本： 1.0, 1.1, 2.0 <br>虽然当前版本的 SDK 不包含墙纸 API，但有些 OEM 通过共享内容目录来支持将图像保存到本地 UI 的墙纸目录中。 <br><br>您可以使用以下代码片断来创建/下载图像到共享目录：<br><br>// 请注意，为了使这个代码起作用，应用程序必须<br>//在 MIF 文件中有"Access to Shared Directory（使用共享目录）" 和 "File（文件）" 的权限。<br>STRCAT( filename, AEE_SHARED_DIR );<br>STRCAT( filename, "/" );<br>STRCAT( filename, "test.gif" );<br>IFILEMGR_OpenFile( m_pIFileMgr, filename, _OFM_CREATE );<br><br>AEE_SHARED_DIR 由 OEM 定义并映射到各设备的特定共享目录路径。 如果 OEM 支持将图像保存至墙纸目录，则保存在 AEE_SHARED_DIR 中的图像会显示在本地 UI 的墙纸目录中。 要查看特定手持设备是否支持通过共享目录保存墙纸图像及支持的图像类型，请参阅手持设备的设备数据表。 <br><br>目前还没有 BREW API 可以用于将特定图像设为手持设备墙纸。 这必须要通过本地 UI 才能完成。 <br><br><span style="COLOR: red">o. 使用 IDISPLAY_BitBlt() 绘制位图时为什么会收到内存错误，如&#8220;memheap.c 0696&#8221;？</span> <br>适用版本： 1.0, 1.1, 2.0 <br>请确保释放 CONVERTBMP 分配的内存。 检查 CONVERTBMP 的最后一个布尔型参数。 如果为 True，则重新分配已完成，必须使用 SYSFREE 来释放内存。 <br><br>例如：<br>pBmp = CONVERTBMP (pDataBytes, &amp;imageInfo, &amp;bVal);<br>IDISPLAY_BitBlt (pIDisplay, xDest, yDest, cxDest, cyDest, pBmp,<br>xSrc, ySrc, dwRopCode);<br><br>IDISPLAY_Update (pIDisplay);<br><br>if(bVal) //仅在完成重新分配时释放<br>SYSFREE (pBmp);<br><br>请参阅 API 参考文档中的 CONVERTBMP 助手函数说明。 若需示例代码，可以参阅 IDisplay 用法示例。 <br><br><span style="COLOR: red">p. 为什么 Emulator 上显示的颜色比预期少？</span> <br>适用版本： 1.0, 1.1, 2.0 <br>如果您在 2.0 模拟器上显示 16 位图像时，图像的分辨率较低，请使用 Device Configurator 检查设备属性并将颜色深度设置为 16 位。 如果图像分辨率仍然很差（相对 8 位或 16 位而言），请检查您是否使用 IIMAGE_SetParm() 函数为要显示的图像设置了不正确的参数。 <br><br><span style="COLOR: red">q. 为什么有些 PNG 图像不能正确显示？</span> <br>适用版本： 1.0, 1.1, 2.0 <br>在 BREW 中使用 PNG 图像需要注意两个问题。 <br>1) 版本 1.0、1.1 和 2.0 不支持 Alpha 通道，但 3.0 SDK 版本应该会支持。 <br>2) BREW 只会选择文件中的第一种透明色对 PNG 进行透明处理。 所有其它颜色都会显示。 请检查文件以确保您创建文件时只使用了一种透明颜色。 <br><br><span style="COLOR: red">r. 为什么创建 PNG 图像使用的内存大小远远大于图像的实际大小？ <br></span>BREW 应用程序使用 ISHELL_LoadResData 加载 PNG 图像时，需要大量的额外空间来解码图像。 例如，要加载 217 字节的 PNG 图像需要 45,177 字节空间
<img src ="http://www.cppblog.com/gtwdaizi/aggbug/62862.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/gtwdaizi/" target="_blank">郭天文</a> 2008-09-27 09:46 <a href="http://www.cppblog.com/gtwdaizi/articles/62862.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>