终于是搞定了PALM的离屏与局部刷新了,但由于PALM OS本身的问题效果并不是很明显
/******************************************************************************
* 函数:InitBitmap
* 功能:创建一个图位并得到位图数据区
* 参数:
* 返回:
* 修改:
******************************************************************************/
static Int16 InitBitmap()
{
UInt32 deep = 16;
UInt8 ena = 1;
UInt16 err;
Err error;
// Set coordinate system to native.
oldCoord = WinSetCoordinateSystem(kCoordinatesStandard);
//Set depth
error = WinScreenMode(winScreenModeSet, NULL, NULL, &deep,&ena );
// Create a nativeFormat offscreen window.
winH = WinCreateOffscreenWindow(LCDWIDTH, LCDHEIGHT, screenFormat, &error);//nativeFormat
if (error)
{
// Restore the old coordinate system.
WinSetCoordinateSystem(oldCoord);
return;
}
bmpP = WinGetBitmap(winH);
// Set the density of the bitmap to low first.
testDep = BmpGetBitDepth(bmpP);
BmpSetDensity(bmpP, kDensityLow);
bitBuffer = BmpGetBits(bmpP);
BmpGetDimensions(bmpP, &bmw, &bmh, &bmrb);
return 1;
}
/******************************************************************************
* 函数:UpdateBitmapData
* 功能:更新位图数据区
* 参数:
* 返回:
* 修改:
******************************************************************************/
Int16 UpdateBitmapData()
{
int x, y, width, height;
if (CHandleEvent(hm,_TIMER, 0, 0))
{
if (CGetUpdateRect(hm,&x, &y, &width, &height))
{
{
UInt32 WinVersion;
RectangleType rect;
Err error;
// Get the window version.
FtrGet(sysFtrCreator, sysFtrNumWinVersion, &WinVersion);
// If doesn't support high density, draw the bitmap here.
if (WinVersion < 4)
{
WinPaintBitmap (bmpP, 0, 0);
return;
}
else
{
UInt32 density;
// Get the density of the screen.
error = WinScreenGetAttribute(winScreenDensity, &density);
if (!error && (density != kDensityDouble))
{
WinDrawBitmap (bmpP, 0, 0);
return;
}
else
{
// Set the draw window to the offscreen window.
oldWinH = WinSetDrawWindow(winH);
rect.topLeft.x = x;
rect.topLeft.y = y;
rect.extent.x = width;
rect.extent.y = height;
// Draw the bitmap on the offscreen window.
WinDrawBitmap(bmpP, 0, 0);
// Set the density of the bitmap to double.
BmpSetDensity(bmpP, kDensityDouble);
// Set the draw window back to main window.
WinSetDrawWindow(oldWinH);
// Copy the bitmap from the offscreen window to main window
WinCopyRectangle(winH, oldWinH, &rect, x, y, winPaint);
// Restore the coordinate system.
WinSetCoordinateSystem(oldCoord);
}
}
}
}
}
return 0;
}