473,324 Members | 2,370 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

View image in picture box from file

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?
Nov 16 '05 #1
5 20011
You have to use FromFile method....

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

Hope it helps,

Ludovic Soeur.
"Fabio" <Fa***@discussions.microsoft.com> a écrit dans le message de
news:51**********************************@microsof t.com...
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?

Nov 16 '05 #2
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

"Fabio" wrote:
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?

Nov 16 '05 #3
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'

"Ludovic SOEUR" wrote:
You have to use FromFile method....

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

Hope it helps,

Ludovic Soeur.
"Fabio" <Fa***@discussions.microsoft.com> a écrit dans le message de
news:51**********************************@microsof t.com...
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?


Nov 16 '05 #4
This one give me errors deployment :(

"pradeep_TP" wrote:
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

"Fabio" wrote:
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?

Nov 16 '05 #5
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?

"Fabio" wrote:
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?

Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: VJ | last post by:
I am looking for ways to store a picture file as a data element in a XML file. Is the below the best option available, to convert a picture file to string format.. string data = null; Bitmap...
1
by: eddie wang | last post by:
How to move around a picture file dynamically in an asp page? Any link to sample code will be great. Thanks. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate...
10
by: Shahnaz | last post by:
Can anybody help me? How to open picture file i.e.bmp of windows through C language? Many Thanks, Shahnaz
4
by: Generic Usenet Account | last post by:
In our environment we have several C++ header files that have some inline member function definitions. For some reason, I am unable to step through the source code of those member functions in my...
4
by: NASAdude | last post by:
I'm working on distributing a database using VS Tools for Office, and am having trouble with linked images on forms/reports. The image objects have a default path\file set on the .Picture property,...
1
by: novadoft | last post by:
hi, i am trying to use the fileSystemObject methods to read a picture file as a text (forcefully), store it in a variable, and then i try writing it back to a file and opening it up with a text...
10
by: Lucas | last post by:
I want to change some pixel value in the picture file. how to do it? If I read the file in binary mode, a bit == a pixel ? Thanks
14
by: Steve K. | last post by:
I have a method that I use to get a System.Drawing.Image from a file without keeping a handle on the file open (so I can delete the file). Here is the code: <code> public static Image...
13
by: bytesc | last post by:
Hey guys, I have created many picture files using gd_library, I recently decided to rename all of my pictures files on my web server to text instead of just numbers. Example: productsssh.jpg ...
0
by: ManSam | last post by:
I have a picture box that is saved to a picture file ".bmp". I inserted the picture in Crystal Report. But when printing, it's not refreshing the new image that's saved in the same file. How can I do...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.