tags:

views:

517

answers:

4

given a path and filename how go i get the image object

Image image = ...(filename)

+3  A: 

You want to call the static FromFile method on the Image class.

casperOne
+1  A: 

Another alternative is to use a Bitmap object (which inherits from Image) like so:

Bitmap bitmap = new Bitmap(imagePath);

(This works for all image formats, not just *.bmp as the name might imply.)

BFree
A: 

If you're playing with images in memory, I've found that bobpowell.net has a GREAT site for GDI work in C#.

No.. I'm not related to, associated with or hired by Bob Powell. I just really enjoy his work. =)

Jerry
A: 
// Get original filename with extention
            string filenameWithPath = "C:\pictures\peanutbutterjellytime.jpg;
            filename = System.IO.Path.GetFileName(filenameWithPath); 
rd42