TRect SrcRect, DestRect; // FMapY是在.h文件中定义的成员变量,代表绘画的起始位置 int Offset = 0 - FMapY; if (Offset > 0) // 头尾截画 { // FBmpMap是在.h文件中定义的Graphic::Tbitmap类型的成员变量 // 用于存入背景图 int tmpY = FBmpMap->Height - Offset; // FBmpBuffer是在.h文件中定义的Graphic::Tbitmap类型的成员变量 // 用于实现双缓冲机制 SrcRect = Rect(FMapX, tmpY, FBmpMap->Width, FBmpMap->Height); DestRect = Rect(FMapX, 0, FBmpMap->Width, Offset); FBmpBuffer->Canvas->CopyRect(DestRect, FBmpMap->Canvas, SrcRect); int OffsetLeave = ClientHeight - Offset; SrcRect = Rect(FMapX, 0, FBmpMap->Width, OffsetLeave); DestRect = Rect(FMapX, Offset, FBmpMap->Width, ClientHeight); FBmpBuffer->Canvas->CopyRect(DestRect, FBmpMap->Canvas, SrcRect); if (Offset == ClientHeight) FMapY = FBmpMap->Height - ClientHeight; } else // 正常截画 { SrcRect = Rect(FMapX, FMapY, ClientWidth, ClientHeight + FMapY); DestRect = Rect(FMapX, 0, ClientWidth, ClientHeight); FBmpBuffer->Canvas->CopyRect(DestRect, FBmpMap->Canvas, SrcRect); } // 绘制到缓冲 FBmpBuffer->Canvas->Draw(FBmpMap->Width, 0, FBmpPanel); // 绘制到窗口 Canvas->Draw(0, 0, FBmpBuffer); |