473,387 Members | 1,897 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,387 software developers and data experts.

How to convert Binarydata to Image

8
hi friends i was new to this forums .in my one of the application i am retriving binarydata from database.

How should i convert this binary data to imageformat..plz help me
my binarydata is:



Report abuse
Feb 5 '07 #1
4 1502
Why are you posting Binary data No need of poasting banary data
ok you can do that use fallowing code to make it
if i am getting images from database which is in Binary
foreach (DataRow dr in ds.Tables[0].Rows)
{
Byte[] imageData = (byte[])dr[0];
string FilaName = dr[1].ToString();
using (MemoryStream ms = new MemoryStream(imageData, 0, imageData.Length))
{

ms.Write(imageData, 0, imageData.Length);

// newImage = Image.FromStream(ms, true);
Bitmap bm = new Bitmap(new MemoryStream(imageData));
newImage = bm;
newImage.Save(path + "\\" + FilaName);

}

}
Feb 5 '07 #2
mshiva
8
Thank u sandeep
Feb 6 '07 #3
mshiva
8
hai sandeep with u r code i am getting error in the following line:

Bitmap bm = new Bitmap(new MemoryStream(imageData));

just i changed code acc to my project:

foreach (DataRow dr in ds.Tables["Photograph"].Rows)
{
byte[] imageData = Convert.FromBase64String(dr["Photograph_Text"].ToString());
string FileName = dr[2].ToString();
using (MemoryStream mst = new MemoryStream(imageData, 0, imageData.Length))
{

Bitmap bmp = new Bitmap(mst);
NewImage =bmp;
NewImage.Save(path + "\\" + FileName);
}
Feb 6 '07 #4
mshiva
8
sorry to inform u about the error:

Parameter is not valid
Feb 6 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Danny | last post by:
There must be a way to convert the binarydata field in the SQL trace output to text data when the event type is a show plan. SQL Profiler does it but how can it be done from an imported table? ...
1
by: Fritz Switzer | last post by:
With two controls a PictureBox and another "PictureBox like" , Pic2, a control from a dll, I'm stuck on cannot implicity convert System.Drawing.Image to System.Drawing.Bitmap error. How do I...
1
by: mevar81 | last post by:
Hello to everybody.I have a problem.I used a TypeDescriptor to retrieve a TypeConverter to convert an Image to a string.The problem is that it converts the image to the string...
1
by: Daniel | last post by:
I have looked everywhere on the web for an answer to this and the only thing I can find is converting the image format when the file is present on the local filesystem. What I want to do is use a...
7
by: Scott Schluer | last post by:
Is there a way to use the Image class to convert a color photo (GIF or JPEG) to a B&W photo? Thanks, Scott
4
by: Kliot | last post by:
I have a string that is a base64 graphic that I need to convert to a file, can someone give me some pointers on how to do this? Thanks
5
by: Socrates | last post by:
I am interested in developing an online utility that will enable users to copy and past any image (or upload any image on the internet) to the online utility, which will then convert the image to...
6
by: PenguinPig | last post by:
Dear All Experts I would like to know how to convert a HTML into Image using C#. Or allow me contains HTML code (parsed) in Image? I also tried this way but it just display the character "<" &...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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,...

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.