使用16K色的位图时,在zire71上只能显示256色,为什么,我用的离屏拷贝方法
使用的函数如下,在pilrc中添入BITMAPCOLOR16K的位图资源,在模拟器上显示正常,在zire71上确失真,只有256色!求助!
// -------------------------------------------------------
// 绘制位图,适用于Palm及OS5以上系统
//
// 参数:pDB -> 资源文件数据库指针
// uwBitmap -> 位图资源的Index或者ID
// x -> 位图左上角的x坐标,低分下的
// y -> 位图左上角的y坐标,低分下的
// bByIndex -> false:根据资源ID来获取Bitmap
// 如果为true,将忽略pDB参数,缺省为false
// -------------------------------------------------------
void UWinDrawBitmap(DmOpenRef pDB, UInt16 uwBitmap, Coord x, Coord y, Boolean bByIndex)
{
MemHandle hResource;
BitmapPtr pResource;
UInt16 uwPrevCoord;
MemHandle hBitmap=0;
BitmapPtr pBitmap;
RectangleType rect;
WinHandle winH, oldWinH;
BitmapPtr pOffBitmap;
Coord wWidth, wHeight;
Err err;
if (bByIndex)
{
if (pDB == NULL) return;
}
// 获取位图资源
pResource = NULL;
if (bByIndex)
hResource = DmGetResourceIndex(pDB, uwBitmap);
else
hResource = DmGetResource(bitmapRsc, uwBitmap);
ErrFatalDisplayIf(! hResource, "Cannot open the bitmap.");
pResource = (BitmapPtr)MemHandleLock(hResource);
// 下面采用高分辨率进行绘制
// 设置Native坐标系
uwPrevCoord = WinSetCoordinateSystem(kCoordinatesNative);
// 先在虚拟窗口中绘图,采用低分辨率绘制
pOffBitmap = NULL;
pBitmap = NULL;
winH = WincreateOffscreenWindow(320, 320, nativeFormat, &err);
if (err)
{
// 恢复坐标系
WinSetCoordinateSystem(uwPrevCoord);
MemPtrUnlock(pResource);
DmReleaseResource(hResource);
return;
}
pOffBitmap = WinGetBitmap(winH);
BmpSetDensity(pOffBitmap, kDensityLow);
oldWinH = WinSetDrawWindow(winH);
// 获取图像大小
BmpGetDimensions(pResource, &wWidth, &wHeight, 0);
WinDrawBitmap(pResource, 0, 0);
rect.topLeft.x = 0;
rect.topLeft.y = 0;
rect.extent.x = wWidth;
rect.extent.y = wHeight;
// 复制到原来的窗口,以高分辨率绘制
BmpSetDensity(pOffBitmap, kDensityDouble);
WinSetDrawWindow(oldWinH);
WinCopyRectangle(winH, 0, &rect, 2 * x, 2 * y, winPaint);
WindeleteWindow(winH,0);
// 恢复坐标系
WinSetCoordinateSystem(uwPrevCoord);
MemPtrUnlock(pResource);
DmReleaseResource(hResource);
}