Solved

Control to load a JPG file - Binary stream

Posted on 2004-03-29
6
286 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
  • 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

757 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now