Solved

Control to load a JPG file - Binary stream

Posted on 2004-03-29
6
291 Views
Last Modified: 2008-02-01
Hi,

is there any control which can load a jpg file by passing the Binary stream.


pls let me know asap.
thanks.
0
Comment
Question by:chandua
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
6 Comments
 
LVL 22

Expert Comment

by:_TAD_
ID: 10709467


No, but you can load an image object from a stream and then drop that Image onto a picturebox.


it will look something like this:

picturebox1.Image = Image.FromStream(myBinaryStream);
0
 

Author Comment

by:chandua
ID: 10716766
hi TAD,

i am creating a Webpart (SPS 2003), i cant have a picture box in it.
0
 

Author Comment

by:chandua
ID: 10717036
hi TAD,

i am trying to get the stream from database
string sqlText = "SELECT img_data FROM Image WHERE img_pk = " + ImageId;
SqlConnection connection = new SqlConnection( ConfigurationSettings.AppSettings["DSN"].ToString() );
SqlCommand command = new SqlCommand( sqlText, connection);
 //open the database and get a datareader
connection.Open();
SqlDataReader dr = command.ExecuteReader();
if ( dr.Read()) //found image
{
 pictureBox1.Image=Image.FromStream((byte[]) dr["img_data"]);
}
i cant pass the dr["img_data"].. how do i convert to straeam/
0
 
LVL 22

Accepted Solution

by:
_TAD_ earned 200 total points
ID: 10719662


Create a Memory Stream.


MemoryStream memStr = new MemoryStream(myByteArray);
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question