如何解决使用多个调色板绘制 4bpp 2D 图块的最佳方法是什么?
我正在创建一个通用的 SNES tilemap 编辑器(类似于 NES Screen Tool),这意味着我正在绘制大量 4bpp 的tile。但是,我的图形循环运行时间太长,即使使用 CachedBitmaps
也无法更改其调色板,我可能需要在 8 个之间切换。我可以处理 SNES 格式和大小的事情,但我在 Windows 方面苦苦挣扎。
// basically the entire graphics drawing routine
case(WM_PAINT):{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd,&ps);
Gdiplus::Graphics graphics(hdc);
graphics.Clear(ARGB1555toARGB8888(CGRAM[0])); // convert 1st 15-bit CGRAM color to 32-bit & clear bkgd
// tileset2[i]->SetPalette(colorpalette); // called in tileset loading to test 1 palette
for(uint16_t i = 0; i < 1024; i++){
tilesetX[i] = new Gdiplus::CachedBitmap(tileset2[i],&graphics);
}
/* struct SNES_Tile{
uint16_t tileIndex: 10,uint16_t palette: 3,uint16_t priority: 1,// (irrelevant for this project)
uint16_t horzFlip: 1,uint16_t vertFlip: 1,}*/
// I can see each individual tile being drawn
for(int y = 0; y < 32; y++){
for(int x = 0; x < 32; x++){
// assume tilemap is set to 32x32,and not 64x32 or 32x64 or 64x64
graphics.DrawCachedBitmap(tilesetX[BG2[y * 32 + x] & 0x03FF],x * BG2CHRSize,y * BG2CHRSize);
// BG2[y * 32 + x] & 0x03FF : get tile index from VRAM and strip attributes
// tilesetX[...] : get CachedBitmap to draw
}
}
EndPaint(hwnd,&ps);
break;
}
我的程序还很早,重写整个图形例程不会太麻烦。
我是否应该放弃 GDI+ 并切换到 Direct2D 或其他?有没有更快的方法来绘制 4bpp 位图而不必为每个调色板创建副本?
编辑:
我的图形绘制程序如此缓慢的原因是我直接在屏幕上绘制。绘制到单独的位图作为缓冲区,然后将缓冲区绘制到屏幕上 快得多。 在绘制到缓冲区时更新图块的调色板会导致完全合理的速度。版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。