Re: Stream into System.Drawing.Image
From: Nicholas Paldino [.NET/C# MVP] (mvp_at_spam.guard.caspershouse.com)
Date: 02/08/05
- Next message: Sumit: "DateTimePicker formatting"
- Previous message: Dennis Myrén: "Re: files required in web page folder"
- In reply to: Josema: "Stream into System.Drawing.Image"
- Next in thread: José María Estrade Nieto: "Re: Stream into System.Drawing.Image"
- Reply: José María Estrade Nieto: "Re: Stream into System.Drawing.Image"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 8 Feb 2005 09:38:32 -0500
Josema,
If you want to show the image back in internet explorer, you probably
don't want to load the bytes into an Image (Bitmap) object. Rather, you
need to return an IMG tag which points to an ASP.NET page. This tag would
have a SRC attribute that has the url of the page, along with an identifier
of some sort in the query string which you can use to fetch the contents of
the image from the database.
Then, in the other ASP.NET page, change the content type of the response
to "image/jpeg" (or whatever your format is), and then fetch the bytes from
the database based on the identifer in the query string. Once you have the
bytes, clear the response stream (the response needs to be buffered for
this, I believe) and then write the bytes in the response stream.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
"Josema" <Jestrade@ocu.org> wrote in message
news:01D6F9D8-A8A7-4120-AF53-27BEEE1EEA88@microsoft.com...
> Hi,
>
> I get from database a field of type binary (its a gif image) into byte[]
> until here no problem, cause i veryfied that the binary its stored into
> the
> byte[] variable (called arrayb in my application).
>
> Im trying show into Internet explorer this byte[] (arrayb its the name of
> the variable) this way:
>
> 1) MemoryStream imgStream=new MemoryStream(arrayb,0,arrayb.Length, false,
> true);
> 2) System.Drawing.Image tmpimg=System.Drawing.Image.FromStream(imgStream);
>
> Question 1) Why im getting an error in the step 2 that says?: Invalid
> parameter used.
>
> Question 2) How could i show the image into a HtmlGenericControl?
> --
> Thanks a lot
> Regards.
> Josema
- Next message: Sumit: "DateTimePicker formatting"
- Previous message: Dennis Myrén: "Re: files required in web page folder"
- In reply to: Josema: "Stream into System.Drawing.Image"
- Next in thread: José María Estrade Nieto: "Re: Stream into System.Drawing.Image"
- Reply: José María Estrade Nieto: "Re: Stream into System.Drawing.Image"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|