本文介绍了如何调用与PaintEventArgs的argumnt功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从MSDN以下code例如:

i have the following code example from 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);
    }

请你能举个例子我怎么能调用这个函数?预先感谢您!

Please can you give example how can I call this function?Thank you in advance!

推荐答案

从Paint事件这样的事情

from the paint event something like this

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

这篇关于如何调用与PaintEventArgs的argumnt功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 05:03