1 Star 0 Fork 0

Abible233/PaintRuler

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Rectanglejuxing.cs 2.07 KB
一键复制 编辑 原始数据 按行查看 历史
Abible233 提交于 2024-08-14 19:16 . 1
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PaintRuler
{
public partial class Rectanglejuxing : Form
{
const int nLength= 1908;
const int nHeight = 101;
public Rectanglejuxing()
{
InitializeComponent();
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
Size picture_size = new Size(nLength, nHeight);
pictureBox1.Size = picture_size;
Font font = new Font("Arial", 90, FontStyle.Bold);
Graphics g = e.Graphics;
g.Clear(Color.White);
Pen pen = new Pen(Color.Black);
//for(int i=0;i<20;i++)
//{
// g.FillRectangle(Brushes.Black, i, i * 500, 800, 500);
// g.DrawString($"{i + 1}", font, Brushes.Black, 980, i * 500 + 250);
//}
//g.DrawLine(pen, 0, 0, nLength - 1, 0);
//g.DrawLine(pen, 0, 0, 0, nHeight - 1);
//g.DrawLine(pen, 0, nHeight - 1, nLength - 1, nHeight - 1);
//g.DrawLine(pen, nLength - 1, 0, nLength - 1, nHeight - 1);
g.FillRectangle(new LinearGradientBrush(new Point(nLength, nHeight), new Point(nLength, -1), Color.FromArgb(181, 181, 182), Color.FromArgb(255, 255, 255)), pictureBox1.ClientRectangle);
}
private void button1_Click(object sender, EventArgs e)
{
Bitmap bitmap = new Bitmap(pictureBox1.Width, pictureBox1.Height);
pictureBox1.DrawToBitmap(bitmap, pictureBox1.ClientRectangle);
// 32转1bit
Bitmap newbitmap = bitmap.Clone(new Rectangle(0, 0, bitmap.Width, bitmap.Height), PixelFormat.Format1bppIndexed);
//bitmap.Dispose();
bitmap.Save($"output\\Rectangle_{nLength}x{nHeight}.bmp", ImageFormat.Bmp);
newbitmap.Dispose();
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/abible233/paint-ruler.git
git@gitee.com:abible233/paint-ruler.git
abible233
paint-ruler
PaintRuler
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385