loading a jpeg

  • Thread starter Thread starter nsgi_2004
  • Start date Start date
N

nsgi_2004

Hello,

I've noticed System.Drawing.Bitmap. I'm wondering if there is an equivalent
class that works with jpegs, or at least loads jpegs and converts them to
bitmaps.

Thanks in advance.
 
nsgi_2004 said:
Hello,

I've noticed System.Drawing.Bitmap. I'm wondering if there is an equivalent
class that works with jpegs, or at least loads jpegs and converts them to
bitmaps.

Thanks in advance.

"bitmap" here is used as a generic term, as opposed to vector graphics.
It is not limited to the bmp format, but can also handle gif, jpeg and more.
Just load a file of that type ...

Hans Kesting
 
I'm not 100% sure on this but you are misunderstanding what the Bitmap class
is. It doesn't really refer to Bmp's but rather pictures that are stored
pixel by pixel. Depending on what you want to do it's, I believe, exactly the
same to load a bmp as a jpg, or png, and a bunch others.

To convert a picture file into an Image Class. use:

Image.FromFile(string path) //for example
this.BackgroundImage = Image.FromFile("Obliterate.jpg");

If you want to edit the file you'll just want to create a Image along with a
Graphics instance.

Image img = Image.FromFile("Obliterate.jpg");
Graphics g = Graphics.FromImage(img);
//then you edit it
g.DrawLine(new Pen(Color.Green), 0, 0, 100, 100);
//etc... and if you want to save
img.Save("new_Obliterate.jpg");

There's much more just be sure to check out the Image class and the Graphics
class for editing. I actually don't remember what the Bitmap class is at the
moment, but it sounds like you don't need to use it. Hope that helps.

Please anyone feel free to tell me how stupid I'm being or something. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top