How to return a Jpg Image as result of a function?

D

Dexter

Hello all,
I have a Class with a function that create a imagem, i need that this
function return a jpg imagem. Somebody know how to make this?



Thanks



Dexter
 
H

Hans Kesting

Dexter said:
Hello all,
I have a Class with a function that create a imagem, i need that this
function return a jpg imagem. Somebody know how to make this?



Thanks



Dexter

The Bitmap class is independent of encoding. You can however convert
the image to a byte[] with some encoding (like jpeg):

Bitmap img = ....
MemoryStream io = new MemoryStream();
img.Save(io, ImageFormat.Jpeg);
byte[] ba = io.GetBuffer();

(namespaces used: System.Drawing, System.Drawing.Imaging, System.IO)

Hans Kesting
 
G

Girish bharadwaj

You will probably need to write your own HttpHandler which will generate the
content-type of jpeg and stuff that to the Response.OutputStream.
Some old code (http://www.devweek.com/code/esposito_graphics.zip) has some
code that shows how to retrieve the image data out of the database and
stream it as the image.
I believe there is some code by Jeff Prosise as well which does similar
thing.
 

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

Members online

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top