gpt4 book ai didi

C# Bitmap To PictureBox 运行不正常

转载 作者:行者123 更新时间:2023-11-30 21:52:50 24 4
gpt4 key购买 nike

我正在尝试制作一些渐变并在不保存的情况下在 pictureBox 中预览它,但它似乎不起作用:

        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;
}

这就是运行这部分代码后 pictureBox 的样子:

最佳答案

删除这一行,因为它处理资源

using (bitmap)

关于C# Bitmap To PictureBox 运行不正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34430889/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com