0
点赞
收藏
分享

微信扫一扫

c#绘制噪点

1.c#绘制噪点

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;

namespace DrawBackground
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
Bitmap image = new Bitmap(100, 22);
Graphics g = Graphics.FromImage(image);
try
{
//生成随机生成器
Random random = new Random();
//清空图片背景色
g.Clear(Color.White);
//画图片的背景噪音线
for (int i = 0; i < 2; i++)
{
Point tem_Point_1 = new Point(random.Next(image.Width), random.Next(image.Height));
Point tem_Point_2 = new Point(random.Next(image.Width), random.Next(image.Height));
g.DrawLine(new Pen(Color.Black), tem_Point_1, tem_Point_2);
}
//画图片的前景噪音点
for (int i = 0; i < 100; i++)
{
Point tem_point = new Point(random.Next(image.Width), random.Next(image.Height));
image.SetPixel(tem_point.X, tem_point.Y, Color.FromArgb(random.Next()));
}
//画图片的边框线
g.DrawRectangle(new Pen(Color.Silver), 0, 0, image.Width - 1, image.Height - 1);
pictureBox1.Image = image;
}
catch { }
}
}
}

2.显示效果

c#绘制噪点_绘制噪点


举报

相关推荐

c#鼠标绘制

C#新加坡国旗的绘制

C#绘制中国象棋

点云数据去噪

C#补充知识点

C# .NetCore知识点

C# 三角形绘制

0 条评论