gpt4 book ai didi

c# - 如何使用 PaintEventArgs 参数调用函数?

转载 作者:太空宇宙 更新时间:2023-11-03 18:38:31 24 4
gpt4 key购买 nike

给定以下来自 MSDN 的代码示例:

private void GetPixel_Example(PaintEventArgs e)
{

// Create a Bitmap object from an image file.
Bitmap myBitmap = new Bitmap(@"C:\Users\tanyalebershtein\Desktop\Sample Pictures\Tulips.jpg");

// Get the color of a pixel within myBitmap.
Color pixelColor = myBitmap.GetPixel(50, 50);

// Fill a rectangle with pixelColor.
SolidBrush pixelBrush = new SolidBrush(pixelColor);
e.Graphics.FillRectangle(pixelBrush, 0, 0, 100, 100);
}

如何调用Paint函数?

最佳答案

在绘画事件中是这样的

private PictureBox pictureBox1 = new PictureBox();

pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox1_Paint);

private void pictureBox1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
GetPixel_Example(e) ;
}

关于c# - 如何使用 PaintEventArgs 参数调用函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11753345/

24 4 0
文章推荐: macros - 普通口齿不清 : Best method to temporarily import a few functions from a package
文章推荐: python - Flask 出现 400 错误
文章推荐: emacs - common lisp 和 emacs lisp 之间的结构区别
文章推荐: HTML