代码拉取完成,页面将自动刷新
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();
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。