binary string to image?http://forums.asp.net/t/1800974.aspx/1?binary+string+to+image+Tue, 08 May 2012 11:35:04 -040018009744969042http://forums.asp.net/p/1800974/4969042.aspx/1?binary+string+to+image+binary string to image? <pre class="prettyprint">foreach (XmlNode customer in customerlist.SelectNodes(&quot;Customer&quot;)) { first_name = customer.SelectSingleNode(&quot;CustomerFirstName&quot;).InnerXml; last_name = customer.SelectSingleNode(&quot;CustomerLastName&quot;).InnerXml; total_orders = customer.SelectSingleNode(&quot;CustomerOrders&quot;).InnerXml; user_image = Convert.FromBase64String(customer.SelectSingleNode(&quot;CustomerPhoto&quot;).InnerXml); output.Text &#43;= &quot;\n &lt;tr&gt;&quot;; output.Text &#43;= &quot;\n &lt;td&gt;&lt;img src=\&quot;photo.png\&quot;&gt;&lt;/td&gt;&quot;; output.Text &#43;= &quot;\n &lt;td&gt;&quot; &#43; first_name &#43; &quot;&lt;/td&gt;&quot;; output.Text &#43;= &quot;\n &lt;td&gt;&quot; &#43; last_name &#43; &quot;&lt;/td&gt;&quot;; output.Text &#43;= &quot;\n &lt;td&gt;&quot; &#43; total_orders &#43; &quot;&lt;/td&gt;&quot;; }</pre> <p>how do i use the variable user_image (of type byte[]) to display the user image ??</p> 2012-05-07T12:13:52-04:004969067http://forums.asp.net/p/1800974/4969067.aspx/1?Re+binary+string+to+image+Re: binary string to image? <p>hi</p> <p>Can you try this function to convert to byte array</p> <p>// C# to convert a string to a byte array. <br> public static byte[] StrToByteArray(string str) <br> { <br> System.Text.UTF8Encoding encoding=new System.Text.UTF8Encoding(); <br> return encoding.GetBytes(str); <br> }<br> and pass the byte array for generating the image<br> public static Image CreateImage(byte[] imageData)<br> {<br> Image image;<br> using (MemoryStream inStream = new MemoryStream())<br> {<br> inStream.Write(imageData, 0, imageData.Length);</p> <p>image = Bitmap.FromStream(inStream);<br> }</p> <p>return image;<br> }</p> <p>Hope it helps,thanks.</p> <pre><span face="Verdana" color="#000000" style="color:#000000; font-family:Verdana"><br></span></pre> 2012-05-07T12:26:07-04:004970374http://forums.asp.net/p/1800974/4970374.aspx/1?Re+binary+string+to+image+Re: binary string to image? <p>the public static image gives me this error</p> <p>Error&nbsp;1&nbsp;'Image' is an ambiguous reference between 'System.Web.UI.WebControls.Image' and 'System.Drawing.Image'</p> <p>edit:</p> <p>i got it to work ..&nbsp;my code had both 'System.Web.UI.WebControls.Image' and 'System.Drawing.Image'</p> <p>.. any way now that it's working..</p> <p>im getting back an image type how do i use it as an html image src?</p> 2012-05-08T08:03:46-04:004970625http://forums.asp.net/p/1800974/4970625.aspx/1?Re+binary+string+to+image+Re: binary string to image? <p>hi</p> <p>try the below code for generating the image from byte array and assign the generated image to the control.</p> <pre class="prettyprint">private void byteArrayToImage(byte[] byteArrayIn) { System.Drawing.Image newImage; string strFileName = GetTempFolderName() &#43; &quot;yourfilename.gif&quot;; if (byteArrayIn != null) { using (MemoryStream stream = new MemoryStream(byteArrayIn)) { newImage = System.Drawing.Image.FromStream(stream); newImage.Save(strFileName); img.Attributes.Add(&quot;src&quot;, strFileName); } lblMessage.Text = &quot;The image conversion was successful.&quot;; } else { Response.Write(&quot;No image data found!&quot;); } }</pre> <p>hope it helps.thanks,<br> <br> </p> 2012-05-08T09:53:31-04:004970708http://forums.asp.net/p/1800974/4970708.aspx/1?Re+binary+string+to+image+Re: binary string to image? <p>what's that ?</p> <p><span class="typ">GetTempFolderName</span><span class="pun">()</span><span class="pln"></span></p> 2012-05-08T10:45:38-04:004970779http://forums.asp.net/p/1800974/4970779.aspx/1?Re+binary+string+to+image+Re: binary string to image? <p>hi</p> <p>that is the function tat returns the path of the tempfoldername. Just return a string showing the path of the folder where you want to save the &nbsp;image.</p> 2012-05-08T11:35:04-04:00