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

How to convert Byte Array into Image Url

53
Hi,

I am developing a simple application Image Zooming using ASP and C#.
In that I used treeview control to display images in different levels or sizes.
Here I am storing the images in database in byte format.
If I click on particular image I am displaying that in Imagebutton.
How can I get image path that is stored in database in byte format.
I want that image path from database.
Please anybody help me.


Thanks in Advance
May 24 '08 #1
2 15480
balame2004
142 100+
Hi,

I am developing a simple application Image Zooming using ASP and C#.
In that I used treeview control to display images in different levels or sizes.
Here I am storing the images in database in byte format.
If I click on particular image I am displaying that in Imagebutton.
How can I get image path that is stored in database in byte format.
I want that image path from database.
Please anybody help me.


Thanks in Advance

Convert byte array into string so now you can get image url
May 26 '08 #2
Frinavale
9,735 Expert Mod 8TB
Hi,

I am developing a simple application Image Zooming using ASP and C#.
In that I used treeview control to display images in different levels or sizes.
Here I am storing the images in database in byte format.
If I click on particular image I am displaying that in Imagebutton.
How can I get image path that is stored in database in byte format.
I want that image path from database.
Please anybody help me.


Thanks in Advance
You could create an ASPX page to serve up your images.
Basically create a new ASPX page and strip out the content...so your ASPX page would look something like:

Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Picture.aspx.vb" Inherits="MyNamespace.Picture" %>
  2.  
Then in your Page_Load you retrieve the image from the database and write that directly to the Response stream....

eg:
Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. 'Instead of reading the file from the server, read it from your database.
  4. 'You will have to pass a Parameter in with your query string that will let this aspx page know what your picture ID in order to retrieve the image from your database.
  5.         Dim fs As FileStream = File.OpenRead(Server.MapPath("~/Images/theImageName.jpg"))
  6.         Dim b(fs.Length) As Byte
  7.         For i = 0 To fs.Length - 1
  8.             b(i) = fs.ReadByte
  9.         Next
  10.         fs.Close()
  11. 'Note that I'm setting the content type to image/jpg...so now when this ASPX page is returned to the browser, it's mime type is set to image/jpg...which the browser will render as an image
  12.        Response.ContentType = "image/jpg"
  13.        Response.BinaryWrite(b)
  14.  
Then for your link button you would set the image url to be aspx page serving up your image.

eg:
Expand|Select|Wrap|Line Numbers
  1. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  2.  
  3.      myImageButton.ImageUrl = "Picture.aspx"
  4.  
  5. 'Since you'll have to pass some ID into your picture aspx page your ImageUrl will look more like:
  6. 'myImageButton.ImageUrl = "Picture.aspx?picId=12345"
  7. End Sub
  8.  
-Frinny
May 26 '08 #3

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

Similar topics

6
by: Gator | last post by:
Hi All, Basically my situation is this, I have a server implemented in C++, unmanaged code, using proprietery protocol over TCP/IP to communicate with the cilent(c++ also). Now, I am implementing...
5
by: Andrew Inwards | last post by:
Can anyone tell me how to convert a byte array to a stream.? Thanks Andrew
4
by: Dan | last post by:
I need to convert a byte array to a string in order to upload a binary file with an httpWebRequest. What's the most efficient way to do such a conversion?
2
by: Dave | last post by:
Hi, I'm trying to convert a byte array to string --This works... System.BitConverter.ToString(bytes) "EB-55-79-20-18-B2-76-4D-85-0A-93-6B-97-33-31-B8" --This doesn't, but returns...
5
by: Terry Olsen | last post by:
Looking for info on how to convert a byte array to a string, and string to byte array. Thanks.
14
by: Charles Law | last post by:
I thought this had come up before, but I now cannot find it. I have a byte array, such as Dim a() As Byte = {1, 2, 3, 4} I want to convert this to an Int32 = 01020304 (hex). If I use...
2
by: shiplu | last post by:
I have an image which I make a byte array. Now I want to store the byte array to the database server through jsp. I have created table & query string. I am facing problem to send request to the jsp
0
by: Sergei Shelukhin | last post by:
Hi. I receive a byte array that contains utf-16 string (with a lot of \0 characters :)) from a legacy system that holds some data that is changed elsewhere. How do I convert it to an actual utf-16...
18
by: MrVS | last post by:
Hi, I have a C++ CLR class method that takes System::Byte *b as parameter argument. I want the CSharp caller pass a byte * to this function. But in the CSharp prorgram, I only managed to create a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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: 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...

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.