对不起,这太长了,我只留下了必要的部分 .
大多数p / invoke东西取自pinvoke.net
我在大图像上平滑平移的解决方案涉及使用 StretchBlt gdi方法而不是 Graphics.DrawImage . 我创建了一个静态类,它将所有本机blitting操作分组 .
另一件有用的事情是缓存 Bitmap 的 HBitmap 和 Graphics 对象 .
public class ZoomPanWindow
{
private Bitmap map;
private Graphics bmpGfx;
private IntPtr hBitmap;
public Bitmap Map
{
get { return map; }
set
{
if (map != value)
{
map = value;
//dispose/delete any previous caches
if (bmpGfx != null) bmpGfx.Dispose();
if (hBitmap != null) StretchBltHelper.DeleteObject(hBitmap);
if (value == null) return;
//cache the new HBitmap and Graphics.
bmpGfx = Graphics.FromImage(map);
hBitmap = map.GetHbitmap();
}
}
}
pro