[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.sdk

Convert Bitmap to JPEG in .NET SDK

Patrick Domegan

11/6/2002 4:58:00 PM

Does anyone know how to convert a bitmap (in memory) to a jpeg image in
memory using the .NET SDK. Is there anything in the System.Drawing
namespace to do this?

Thanks


2 Answers

Cowboy \(Gregory A. Beamer\)

11/6/2002 5:40:00 PM

0

You can certainly change a bitmap type to JPG using GDI+. Of course, the
process is aimed at saving the JPG off as a file, which works well in most
cases. I have not checked to see if there is an overload to save this off to
a stream, which would serve your purpose well.

Note that the GDI+ is marginal with most web formats. GIF is a complete
joke, due to the Unisys patent. PNG is very good, but only applicable to the
latest browsers. JPG is okay, but not as flexible as it is in graphics
programs.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
Author: ADO.NET and XML: ASP.NET on the Edge

****************************************************************************
****
Think outside the box!
****************************************************************************
****
"Patrick Domegan" <patrick@carmelvision.com> wrote in message
news:#7yvzzahCHA.2592@tkmsftngp09...
> Does anyone know how to convert a bitmap (in memory) to a jpeg image in
> memory using the .NET SDK. Is there anything in the System.Drawing
> namespace to do this?
>
> Thanks
>
>


Julio Negron

11/6/2002 8:53:00 PM

0

To save an image in a different format simply change the ImageFormat
paramater
in the Save method of the bitmap object.

'instantiate an instance of the bitmap object with the old image
Dim myBitmap as Bitmap = New Bitmap("c:\images\oldbitmap.bmp")

'to save it to a directory
myBitmap.Save("c:\images\newbitmap.jpg", ImageFormat.JPEG)

'or to stream it to a browser
Response.ContentType = "image/jpg"
myBitmap.Save(Response.OutputStream, ImageFormat.JPEG)

Julio Negron
.NET Junkie
:-)

"Patrick Domegan" <patrick@carmelvision.com> wrote in message
news:#7yvzzahCHA.2592@tkmsftngp09...
> Does anyone know how to convert a bitmap (in memory) to a jpeg image in
> memory using the .NET SDK. Is there anything in the System.Drawing
> namespace to do this?
>
> Thanks
>
>