wince 绘图中使用橡皮擦
2010-09-06 08:07:00 来源:WEB开发网这里说的绘图使用橡皮擦,就是把蒙在表面的图片擦掉,显示里面的图片。
原理很简单,就是用被蒙着的图片来创建一个画刷,然后在mousemove里面绘图就可以了
代码如下:
using System;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Reflection;
namespace phone_r1
{
public partial class Form1 : Form
{
[DllImport("coredll.dll",EntryPoint="CreatePen")]
public static extern IntPtr CreatePen(int nPenStyle, int nWidth, int color);
[DllImport("coredll.dll", EntryPoint = "CreatePatternBrush")]
public static extern IntPtr CreatePatternBrush(int hBitmap);
[DllImport("coredll.dll", EntryPoint = "SelectObject")]
private extern static IntPtr SelectObject(IntPtr hdc, IntPtr obj);
[DllImport("coredll.dll", EntryPoint = "DeleteObject")]
private extern static bool DeleteObject(IntPtr obj);
[DllImport("coredll.dll", EntryPoint = "Ellipse")]
private extern static bool Ellipse(IntPtr hdc,int x1,int y1,int x2,int y2 );
private const int NULL_PEN = 5;
//string[] strArr;
//屏幕绘图对象
private Graphics ScreenGraphics;
//内存绘图对象
private Graphics BufferGraphics;
//内存图
private Bitmap imgOffscreen;
bool IsDown = false;
Bitmap bmp;
#region ......
//画刷句柄
private IntPtr g_hBrush;
更多精彩
赞助商链接