WEB开发网
开发学院手机开发Windows Mobile 开发 wince 绘图中使用橡皮擦 阅读

wince 绘图中使用橡皮擦

 2010-09-06 08:07:00 来源:WEB开发网   
核心提示://画笔句柄private IntPtr g_hPen;IntPtr g_hdc;IntPtr g_oldp;IntPtr g_oldb;#endregionpublic Form1(){InitializeComponent();bmp = new Bitmap(System.IO.Path.GetDirectory

//画笔句柄

private IntPtr g_hPen;

IntPtr g_hdc;

IntPtr g_oldp;

IntPtr g_oldb;

#endregion

public Form1()

{

InitializeComponent();

bmp = new Bitmap(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase) + "\PIC\a20.bmp");

//图片句柄

int ibmp = bmp.GetHbitmap().ToInt32();

//画刷句柄

g_hBrush = CreatePatternBrush(ibmp);

ScreenGraphics = this.CreateGraphics();

imgOffscreen = new Bitmap(240, 320);

BufferGraphics = Graphics.FromImage(imgOffscreen);

BufferGraphics.FillRectangle(new SolidBrush(Color.White), new Rectangle(0, 0, 240, 320));

g_hdc = BufferGraphics.GetHdc();

g_hPen = CreatePen(NULL_PEN, 1, 0);

IntPtr oldp = SelectObject(g_hdc, g_hPen);

IntPtr oldb = SelectObject(g_hdc, g_hBrush);

}

//private void Form1_Paint(object sender, PaintEventArgs e)

//{

//}

protected override void OnPaint(PaintEventArgs e)

{

ScreenGraphics.DrawImage(imgOffscreen, 0, 0);

}

protected override void OnPaintBackground(PaintEventArgs e)

{

//base.OnPaintBackground(e);

}

private void Form1_MouseDown(object sender, MouseEventArgs e)

{

IsDown = true;

}

///

/// 颜色值转换

///

///

///

private static int ColorToCOLORREF(Color color)

{

return ((color.R | (color.G << 8)) | (color.B << 16));

}

private void Form1_MouseMove(object sender, MouseEventArgs e)

{

Ellipse(g_hdc, e.X - 10, e.Y - 10, e.X + 10, e.Y + 10);

Tags:wince 绘图 使用

编辑录入:coldstar [复制链接] [打 印]
赞助商链接