473,385 Members | 2,028 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,385 software developers and data experts.

how can i load jpg from file

Hello
I finally managed to save Bitmap that reprezented my pictureBox to jpg
file, but now how can i load from that file to Bitmap again ?
Bitmap does not have any Load or Open method (like Save...).
Thanx
Michal

Nov 16 '05 #1
3 21331
APG
us**@domain.invalid wrote:
Hello
I finally managed to save Bitmap that reprezented my pictureBox to jpg
file, but now how can i load from that file to Bitmap again ?
Bitmap does not have any Load or Open method (like Save...).
Thanx
Michal

Hi,

One option is using the constructor to load the file. The Bitmap class
constructor has many overloads and one of it accepts the file name as
parameter.

HTH,
APG
Nov 16 '05 #2
Hi Michal,
Hello
I finally managed to save Bitmap that reprezented my pictureBox to jpg
file, but now how can i load from that file to Bitmap again ?
Bitmap does not have any Load or Open method (like Save...).
Thanx
Michal


To load any image you can call:
Image.FromFile(...)

If image if a JPEG then You can cast it to Bitmap.
e.g. Bitmap myJpeg=(Bitmap) Image.FromFile("myJpegPath");

Regards

Marcin
Nov 16 '05 #3
> Hello
I finally managed to save Bitmap that reprezented my pictureBox to jpg
file, but now how can i load from that file to Bitmap again ?
Bitmap does not have any Load or Open method (like Save...).

Something like this, this prevents locking the file too long.

public void Load(string asFile) {
//--- Because Image keeps th file locked untill the garbage collector
releases it, we have
// to make it released as soon a possible using this trick.
Stream BitmapStream =
System.IO.File.Open(asFile,System.IO.FileMode.Open );
Image imgPhoto = Image.FromStream(BitmapStream);
BitmapStream.Close();

//--- Now the file is beeing released continue using the contents.
mBitmap=new Bitmap(imgPhoto);
}
Nov 16 '05 #4

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

Similar topics

1
by: Ray in HK | last post by:
What are the differences between LOAD DATA INFILE and LOAD DATA LOCAL INFILE ? I found some web hosting company do not allow using LOAD DATA INFILE but allow LOAD DATA LOCAL INFILE. The reason...
5
by: kk | last post by:
Hello, I am using the udb 8.1 task scheduler to schedule a load. Is there any way to also schedule an OS command (win32) to delete the file after the load? I have a python script that will do...
0
by: Simon | last post by:
Hi I try to open a CR report file located on the network path from a web form developed with vs2003 and CR for Visual Studio, but the Load method of ReportDocument object always return error. ...
3
by: nsh | last post by:
mailing.database.mysql, comp.lang.php subject: does "LOAD DATA" EVER work?!? I've tried EVERYTHING! version info: my isp is running my web page on a linux box with php ver. 4.4.1 according to...
4
by: andrewcw | last post by:
I am moving some code forward from .NET 1.1. I was able to load the XSL file and perform the transform. The MSDN documentation looks like it should be easy. But I get a compile error. Ideas ?...
0
by: giovanni gherdovich | last post by:
Hello, first of all: Is this the right place to ask plastek-related questions? I'm trying to make plastex work on my Ubuntu Dapper Drake. For LaTeX, I have the all-in-one package tetex.
2
by: contractsup | last post by:
Environment: $ uname -a AIX <withheld2 5 000100614C00 $ db2level DB21085I Instance "<withheld>" uses "32" bits and DB2 code release "SQL08024" with level identifier "03050106"....
10
by: lamxing | last post by:
Dear all, I've spent a long time to try to get the xmldocument.load method to handle UTF-8 characters, but no luck. Every time it loads a document contains european characters (such as the...
2
by: David Thielen | last post by:
So we have moved our app from .NET version 2.X in IIS6 to a Windows 2008 Server running IIS7. We have copied all files to the Windwardreports\apps directory and that apps directory has been...
13
by: rdudejr | last post by:
Hi all, I hardly ever make a post unless I am having a very purplexing issue, so this one should be good... I am trying to do a load against a database on an AIX server into a DB2 v9.1...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.