change the following code [modified]
-
private void btnOOImg_Click(object sender, EventArgs e)
{
string imgFileName;
Bitmap img = null;
Color c;
int i, j;
openFileDialog1.Filter = "All Image Files|*.bmp;*.ico;*.cur|All files (*.*)|*.*";
openFileDialog1.FileName = null;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
imgFileName = openFileDialog1.FileName;
img = (Bitmap)Image.FromFile(imgFileName);
for (i = 0; i < img.Width - 1; i++)
{
for (j = 0; j < img.Height - 1; j++)
{
c = img.GetPixel(i, j);
imgO[i, j] = c.R;
// MessageBox.Show("" + imgO[i, j]);
}
}
picOriginal.Image = img;
}
}this code restricts certain images. i want it to change accept all images in as a file not inside a picture box
modified on Tuesday, December 7, 2010 11:55 AM
-
private void btnOOImg_Click(object sender, EventArgs e)
{
string imgFileName;
Bitmap img = null;
Color c;
int i, j;
openFileDialog1.Filter = "All Image Files|*.bmp;*.ico;*.cur|All files (*.*)|*.*";
openFileDialog1.FileName = null;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
imgFileName = openFileDialog1.FileName;
img = (Bitmap)Image.FromFile(imgFileName);
for (i = 0; i < img.Width - 1; i++)
{
for (j = 0; j < img.Height - 1; j++)
{
c = img.GetPixel(i, j);
imgO[i, j] = c.R;
// MessageBox.Show("" + imgO[i, j]);
}
}
picOriginal.Image = img;
}
}this code restricts certain images. i want it to change accept all images in as a file not inside a picture box
modified on Tuesday, December 7, 2010 11:55 AM
The formats supported by the
Image
class are listed here[^]. Simply change yourOpenFileDialog
Filter
to include those you are interested in.Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
The formats supported by the
Image
class are listed here[^]. Simply change yourOpenFileDialog
Filter
to include those you are interested in.Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
i tried changing.i have a index error. can you give me a particular sytax
-
i tried changing.i have a index error. can you give me a particular sytax
You currently have:
openFileDialog1.Filter = "All Image Files|\*.bmp;\*.ico;\*.cur|All files (\*.\*)|\*.\*";
To add a filter for PNG files (for example) simply add the filename template between 'cur' and the '|' before 'All Files', not forgetting to separate it by a semi-colon.
openFileDialog1.Filter = "All Image Files|\*.bmp;\*.ico;\*.cur**;\*.png**|All files (\*.\*)|\*.\*";
I have tried to make my additions stand out by superscripting it. Have a go with the others yourself.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”