Re: Stream into System.Drawing.Image

From: Nicholas Paldino [.NET/C# MVP] (mvp_at_spam.guard.caspershouse.com)
Date: 02/08/05


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 


Relevant Pages

  • Re: multiple tables, composite keys
    ... Ok, I ditched the composite keys, the tag numbers are unique anyway. ... Will make a separate post. ... I have a database where my client have a set spec for how the tables ...
    (microsoft.public.access.forms)
  • Re: PROBLEM SOLVED - State of WORKING-STORAGE in Statically-Called Subroutines
    ... I went through the entire database, making static HTML pages that used ... Straight HTML - no CSS. ... This tag tells the ... I then format these using XSLT. ...
    (comp.lang.cobol)
  • Re: Accessing forms properties
    ... module in the database sometime in the future. ... > Ron W ... >> solution looks like the way to go - much better than using the Tag ...
    (microsoft.public.access.formscoding)
  • Re: Scott, you got get on this program...
    ... west on the 91 Express Lanes, for free, for the 470th time. ... There's too much reliance on database retrieval instead of using the obvious feedback from the immediate situation. ... confidential basis to do anything but protect themselves," Garden Grove ... The most likely method of finding a person is stalking, not breaking into a tag database and using a street map. ...
    (rec.autos.driving)
  • Re: problem in uploading and downloading files from DB in ASP.Net
    ... my problem is only this that i dont know that how to download ... > the physical file stored in a table of SQL server database (datatype ... You cannot use HttpPostedFile for this. ... file's bytes stored in the database to the response stream, ...
    (microsoft.public.dotnet.framework.aspnet)