المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Error in declaring a bitmap as the .image of a picture box



C# Programming
04-26-2009, 05:59 AM
I have a function that takes the image in a picture box and converts it to a bitmap (System.Drawing.Image Picturebox.Image to System.Drawing.Bitmap) with the following code:


private void freezeFrame_MouseClick(object sender, MouseEventArgs e)
{
Bitmap refImage = new Bitmap(freezeFrame.Image); //freezeFrame = picture box control

int rangeLimit = 20;
txtMouseX.Text = e.X.ToString();
txtMouseY.Text = e.Y.ToString();
int mouseX = int.Parse(txtMouseX.Text);
int mouseY = int.Parse(txtMouseY.Text);



Color currentPixel = (refImage.GetPixel(mouseX, mouseY));

curPixelRed.Text = currentPixel.R.ToString();
curPixelGreen.Text = currentPixel.G.ToString();
curPixelBlue.Text = currentPixel.B.ToString();

redMinUpDown.Value = currentPixel.R - rangeLimit;
redMaxUpDown.Value = currentPixel.R + rangeLimit;

greenMinUpDown.Value = currentPixel.G - rangeLimit;
greenMaxUpDown.Value = currentPixel.G + rangeLimit;

blueMinUpDown.Value = currentPixel.B - rangeLimit;
blueMaxUpDown.Value = currentPixel.B + rangeLimit;


}




I keep getting an invalid parameter error for the first line of the function. What am I doing wrong?