using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;//GDI+渲染力更强的类的命名空间
namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
Graphics g;//画布
Bitmap bmp;//图片
public Form2()
{
InitializeComponent();
//实例化一个图片
bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);
g = Graphics.FromImage(bmp);//以一个图片来创建一个画布
g.Clear(Color.White);//设置画布的背景颜色
pictureBox1.Image = bmp;//画出来的东西显示出来
}
public Color Color = Color.Red;//画笔的颜色
public int lineWidth = 1;//线条的宽度
private void button2_Click(object sender, EventArgs e)
{
ColorDialog cd = new ColorDialog();
if (cd.ShowDialog()==DialogResult.OK)
{
button2.BackColor = cd.Color;
Color = cd.Color;
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
lineWidth = int.Parse(comboBox1.Text);
}
int type = 0;//1为矩形 2为饼
private void button1_Click(object sender, EventArgs e)
{
type = 1;
&nbs
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;//GDI+渲染力更强的类的命名空间
namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
Graphics g;//画布
Bitmap bmp;//图片
public Form2()
{
InitializeComponent();
//实例化一个图片
bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);
g = Graphics.FromImage(bmp);//以一个图片来创建一个画布
g.Clear(Color.White);//设置画布的背景颜色
pictureBox1.Image = bmp;//画出来的东西显示出来
}
public Color Color = Color.Red;//画笔的颜色
public int lineWidth = 1;//线条的宽度
private void button2_Click(object sender, EventArgs e)
{
ColorDialog cd = new ColorDialog();
if (cd.ShowDialog()==DialogResult.OK)
{
button2.BackColor = cd.Color;
Color = cd.Color;
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
lineWidth = int.Parse(comboBox1.Text);
}
int type = 0;//1为矩形 2为饼
private void button1_Click(object sender, EventArgs e)
{
type = 1;
&nbs

这篇博客详细介绍了如何使用C#的GDI+库进行图形绘制,包括椭圆等基本图形的创建方法,适合C#开发者学习图形编程。
最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



