GDI+ C# 在图片上画矩形
来源:互联网 发布:西安少儿编程培训班 编辑:程序博客网 时间:2024/04/30 01:17
//定义全局变量
private int pointStartX, pointStartY, pointEndX, pointEndY
private Bitmap bitmapSource = null;
//初始化中
string strPath = "C:\\Users\\Public\\Pictures\\Sample Pictures\\22.jpg";
bitmapSource = new Bitmap(strPath);
//在MouseDown事件中记下起始点
pointStartX = e.X;
pointStartY = e.Y;
//C#中利用GDI+ ,在MouseMove事件中绘制矩形
int iWidth = e.X - pointStartX;
int iHeight = e.Y - pointStartY;
if (e.Button == MouseButtons.Left)
{
// 每次鼠标移动都拷贝原图bitmapSource,去除之前的留下的矩形
Bitmap bitmap = new Bitmap(bitmapSource, 500, 500);
Pen pen = new Pen(Color.Red);
Graphics gh = Graphics.FromImage(bitmap);
Rectangle rectNew = new Rectangle(pointStartX, pointStartY, iWidth, iHeight);
// 画矩形
gh.DrawRectangle(pen, rectNew);
// 显示在画板上
this.CreateGraphics().DrawImage(bitmap, 0, 0, 500, 500);
}
- GDI+ C# 在图片上画矩形
- 用setmousecallback在图片上画矩形框--鼠标事件
- 用鼠标在图片上画矩形框
- python在图片上画特定大小角度矩形框
- GDI/GDI+ 在图像上画直线
- C# 用GDI在图片上写字实现lable透明背景
- C# GDI在控件上绘图
- c#在已有图片上打水印打码打矩形区域标记等
- c#判断点是否在矩形上
- c# winfrom 在panel上绘制矩形
- gdi+(2) 画矩形
- C# GDI+ 画简单的图形:直线、矩形、扇形等
- Android画圆角矩形图片,并在图片上写字
- C# GDI+ 绘制圆角实心矩形
- C#图片处理之:在图片上画直线
- C#图片处理之:在图片上画直线
- android 在图片(bitmap)上画矩形框,并显示
- C# 如何在图像上做(矩形/圆)标记
- 第三季度全球手机安全报告:手机感染量超上半年总和
- animation 实现果冻突出效果
- 如何快速成为优秀的IT系统集成服务工程师?
- ubuntu12.10下编译chrome时执行/src/build/install-build-deps.sh出错
- vim配置及实现
- GDI+ C# 在图片上画矩形
- Linux Mint 13 的安装、配置及搭建Android源码编译环境
- 关于Android模拟键盘使用的注意事项
- 双机热备与负载均衡区别
- 【译】Simple MySQL ORM for C
- c语言中容易混淆的概念
- perl web框架
- android安全
- sqlite加密-SQLCipher