473,394 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Stream into System.Drawing.Image

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
Nov 16 '05 #1
2 13442
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]
- mv*@spam.guard.caspershouse.com

"Josema" <Je******@ocu.org> wrote in message
news:01**********************************@microsof t.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

Nov 16 '05 #2

Hi Nicholas, first to all agree to you for the fast answer,

My exactly problem its that:

I have in a database models of cars,

CarID int
CarName varchar
CarFeatures varchar
CarImage binary

I have a class Car that have the properties:
ID int
Name string
Features string
Image byte[]

My problem its that i have into a page a

<span id=CarGenericControl runat=server>

and inside the CarGenericControl.InnerHtml

I have to show the Name, Features, and Image foto of the car.

In this moment i show all the information except the foto, that i dont
know how to put it from byte[] into the Generic Control.

Do you have any advice for this specific case?

Thanks.
Kind Regards.
Josema
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Li Zhang | last post by:
I have a problem with reading byte from a memory stream. Basically I want to resize a image and then store them to sql server. Here is part of the codes. every time I tried to read byte from...
8
by: TJ | last post by:
I need to be able to pass a pointer to a (managed code) Stream object to a COM method so it can serialize its data into the stream. I have a C# application that makes uses of Randolf Duke's...
11
by: Detlef Hüttenbach | last post by:
Whereas loading tiffs and pngs from file into an Image WebControl work, the images aren't shown when loaded from streams: In a WebForm, the image's property "ImageUrl" is set to a handler, and...
2
by: Raed Sawalha | last post by:
I have seen on some websites, image references that instead of image, are other ASP, ASP.NET or CGI pages. The link would be like <img src="imagegenerator.asp?imageid=1235">. I would like to use...
2
by: creepwood | last post by:
I'm trying to load and image into a DB and alongside the image also a thumbnailed version of the image, but somewhere in my code, the stream doesn't take the thumbnail data. When I just change toe...
0
by: Dennis | last post by:
I have the following: Dim stream As New IO.MemoryStream fmParent.Icon = icon.FromHandle(New IntPtr(retval)) frmParent.Icon.Save(stream) 'RESIZE ICON to 16 x 16 Dim im As Image im =...
4
by: John Daly | last post by:
Does anyone know how to create an image (JPEG) from an HTTPResponse object? I am working on system that has a map pop up from our GIS department. I want create an image at runtime from this popup...
3
by: forest demon | last post by:
for example, let's say I do something like, System.Diagnostics.Process.Start("notepad.exe","sample.txt"); if the user does a SaveAs (in notepad), how can i capture the path that the user...
0
by: Iridium | last post by:
Greetings, I am trying to get a JPG Frame from a MJPG Stream. A MJPG is basically a stream of JPGs which are splitted by a special boundary string. So I tried to get the stream, split it by the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.