2
我試圖做一些梯度&預覽它在PictureBox不保存,但它似乎不工作:C#位圖圖片框無法正常工作
if (isChanged == true)
{
re = new Rectangle(0, 0, int.Parse(textBox5.Text), int.Parse(textBox4.Text));
currectBrush = new System.Drawing.Drawing2D.LinearGradientBrush(re, System.Drawing.ColorTranslator.FromHtml("#FC00FF"), System.Drawing.ColorTranslator.FromHtml("#00DBDE"), -45f); ;
bitmap = new Bitmap(int.Parse(textBox5.Text), int.Parse(textBox4.Text));
using (bitmap)
using (var graphics = Graphics.FromImage(bitmap))
{
currectBrush = new System.Drawing.Drawing2D.LinearGradientBrush(re, System.Drawing.ColorTranslator.FromHtml(textBox1.Text), System.Drawing.ColorTranslator.FromHtml(textBox2.Text), int.Parse(textBox3.Text));
graphics.FillRectangle(currectBrush, re);
pictureBox1.Image = bitmap;
}
isChanged = false;
}
而且這是圖片框的樣子運行此之後部分代碼:
貝特r切換到WPF而不是WinForm。它會給你更多的靈活性和易用性。 –