View image in picture box from file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

private void Apri_Click(object sender, System.EventArgs e)
{
OpenFileDialog fileChooser=new OpenFileDialog();

//fileChooser.Filter="tiff images (*.tiff)|*.tiff";

DialogResult result = fileChooser.ShowDialog();

Image immagine = New Image(fileChooser.FileName);

PictureBox.Image = immagine;
}

where's the error?
 
You have to use FromFile method....

Image immagine = Image.FromFile(fileChooser.FileName);
pictureBox1.Image = immagine;

Hope it helps,

Ludovic Soeur.
 
HI Fabio,

Replace the following statement in your code

Image immagine = New Image(fileChooser.FileName);

with this.

System.Drawing.Bitmap immagine = new Bitmap(fileChooser.FileName);

You can assign only a bitmap object to the image property of the PictureBox

happy programming!!
pradeep_TP
 
if i write this

Image immagine = Image.FromFile(fileChooser.FileName);
pictureBox1.Image = immagine;


tell me

'System.Drawing.Image' does not contain a definition for 'FromFile'
 
This one give me errors deployment :(

pradeep_TP said:
HI Fabio,

Replace the following statement in your code

Image immagine = New Image(fileChooser.FileName);

with this.

System.Drawing.Bitmap immagine = new Bitmap(fileChooser.FileName);

You can assign only a bitmap object to the image property of the PictureBox

happy programming!!
pradeep_TP
 
The code that you give me are good but they don't work for my application
cause is a program for a pocket pc. Why there's a lot of problem to develop
an application for a pocket pc? How can i do to open an image for a ppc?
 
Back
Top