代码拉取完成,页面将自动刷新
using System.Drawing;
using System;
namespace KaiwaProjects
{
class KP_DrawEngine
{
/// <summary>
/// Original class to implement Double Buffering by
/// NT Almond
/// 24 July 2003
///
/// Extended and adjusted by
/// Jordy "Kaiwa" Ruiter
/// </summary>
///
private Graphics graphics;
private Bitmap memoryBitmap;
private int width;
private int height;
public void Dispose()
{
if (graphics != null)
{
graphics.Dispose();
}
if (memoryBitmap != null)
{
memoryBitmap.Dispose();
}
}
public KP_DrawEngine()
{
try
{
width = 0;
height = 0;
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show("ImageViewer error: " + ex.ToString());
}
}
public bool CreateDoubleBuffer(Graphics g, int width, int height, int previewWidth, int previewHeight)
{
try
{
KaiwaProjects.KP_DrawObject.UpdatePanelsize(width, height);
KaiwaProjects.KP_DrawObject.UpdatePreviewPanelsize(previewWidth, previewHeight);
if (memoryBitmap != null)
{
memoryBitmap.Dispose();
memoryBitmap = null;
}
if (graphics != null)
{
graphics.Dispose();
graphics = null;
}
if (width == 0 || height == 0)
return false;
this.width = width;
this.height = height;
memoryBitmap = new Bitmap(width, height);
graphics = Graphics.FromImage(memoryBitmap);
return true;
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show("ImageViewer error: " + ex.ToString());
return false;
}
}
public void Render(Graphics g)
{
try
{
if (memoryBitmap != null)
{
g.DrawImage(memoryBitmap, new Rectangle(0, 0, width, height), 0, 0, width, height, GraphicsUnit.Pixel);
}
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show("ImageViewer error: " + ex.ToString());
}
}
public bool CanDoubleBuffer()
{
try
{
return graphics != null;
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show("ImageViewer error: " + ex.ToString());
return false;
}
}
public Graphics g
{
get
{
return graphics;
}
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。