使用16K色的位图时,在zire71上只能显示256色,为什么,我用的离屏拷贝方法

sinypan 2005-03-04 03:44:40
使用的函数如下,在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);
}

...全文
71 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
sinypan 2005-03-04
  • 打赏
  • 举报
回复
谢谢,我现在解决了,在应用程序启动时,使用下面方法完成了颜色的初始化,这样就正常了。

//设定屏幕的色彩深度
static UInt32 SetScreenMode()
{
UInt32 depth,attr,version;
Err err;

err = FtrGet( sysFtrCreator, sysFtrNumWinVersion, &version );
if( !err&&( version>3 ) )
{
WinScreenGetAttribute( winScreenDensity, &attr );
if ( attr == kDensityDouble )
{
WinScreenMode( winScreenModeGetSupportedDepths,NULL,NULL,&depth,0 );
if( GetBitMacro( depth,15 )!=0 )
{
depth=16;
WinScreenMode( winScreenModeSet, 0, 0, &depth, 0 );
}
else
{
depth=8;
WinScreenMode( winScreenModeSet, 0, 0, &depth, 0 );
}
}
else if( attr == kDensityLow )
{
depth=8;
WinScreenMode( winScreenModeSet, 0, 0, &depth, 0 );
}
}
return(depth);
}
sinon 2005-03-04
  • 打赏
  • 举报
回复
检查一下程序是否有初始化屏幕颜色深度为16位色.

很多SIMULATOR默认状态为16BIT色,而真实机器是8BIT.

3,120

社区成员

发帖
与我相关
我的任务
社区描述
塞班系统(Symbian系统)是塞班公司为手机而设计的操作系统,它的前身是英国宝意昂公司的 EP ( Electronic Piece of cheese)操作系统。
社区管理员
  • Symbian社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧