473,472 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to display in-memory image?

I'm getting an array of bytes returned from a web service representing a
jpeg image. How can I display this on an asp.net page? The Image control
seems only to take an URL as a paremeter.

Olav
Nov 18 '05 #1
6 2227
Hello Olav,

An image is going to constitue another request, so what you'll need do is
assign the Image URL to a page or handler in your website. This page/handler
will have code something like this:

byte[] buffer = someMethodToGetTheByteArray();
Response.ContentType = "image/jpeg";
Response.BinaryWrite(buffer);
Response.End();

--
Matt Berther
http://www.mattberther.com
I'm getting an array of bytes returned from a web service representing
a jpeg image. How can I display this on an asp.net page? The Image
control seems only to take an URL as a paremeter.

Olav

Nov 18 '05 #2
I can't see how this is practical. The web service returns an array of
photos. Each photo contains a byte array containing the jpeg images for some
thumbnails. How can I then use the URL or page handler? I don't think it
would be a good idea to do a web service call in the page handler to get
photos one by one either.

Any other ways to do this?

Olav

"Matt Berther" <mb******@hotmail.com> wrote in message
news:OM****************@TK2MSFTNGP12.phx.gbl...
Hello Olav,

An image is going to constitue another request, so what you'll need do is
assign the Image URL to a page or handler in your website. This
page/handler will have code something like this:

byte[] buffer = someMethodToGetTheByteArray();
Response.ContentType = "image/jpeg";
Response.BinaryWrite(buffer);
Response.End();

--
Matt Berther
http://www.mattberther.com
I'm getting an array of bytes returned from a web service representing
a jpeg image. How can I display this on an asp.net page? The Image
control seems only to take an URL as a paremeter.

Olav


Nov 18 '05 #3
I have seen applications doing something like this:

getphoto.aspx?key=B59273C3BB30A9AD7AD5

Instead of using the web service to transfer the byte array back to the
client, it generates a URL with a uniqueue key and feed that back to the
client. Then the image is fetche as you suggested dynamically when the
browser requests the URL. In addition, the key expires after a while to keep
access control to the server.

How do you implement something like this? Is it easily supported by the .NET
framework or do I have to do a lot of hand-coding for this scenario?

Olav

"Matt Berther" <mb******@hotmail.com> wrote in message
news:OM****************@TK2MSFTNGP12.phx.gbl...
Hello Olav,

An image is going to constitue another request, so what you'll need do is
assign the Image URL to a page or handler in your website. This
page/handler will have code something like this:

byte[] buffer = someMethodToGetTheByteArray();
Response.ContentType = "image/jpeg";
Response.BinaryWrite(buffer);
Response.End();

--
Matt Berther
http://www.mattberther.com
I'm getting an array of bytes returned from a web service representing
a jpeg image. How can I display this on an asp.net page? The Image
control seems only to take an URL as a paremeter.

Olav


Nov 18 '05 #4
if you switch to netscape or firefox, they support inline images. for IE you
are stuck with a url reference.

<img src="data:image/gif;base64,GIFDATAINBASE64" />

-- bruce (sqlwork.com)

"Olav Tollefsen" <x@y.com> wrote in message
news:Oq*************@TK2MSFTNGP11.phx.gbl...
I can't see how this is practical. The web service returns an array of
photos. Each photo contains a byte array containing the jpeg images for some thumbnails. How can I then use the URL or page handler? I don't think it
would be a good idea to do a web service call in the page handler to get
photos one by one either.

Any other ways to do this?

Olav

"Matt Berther" <mb******@hotmail.com> wrote in message
news:OM****************@TK2MSFTNGP12.phx.gbl...
Hello Olav,

An image is going to constitue another request, so what you'll need do is assign the Image URL to a page or handler in your website. This
page/handler will have code something like this:

byte[] buffer = someMethodToGetTheByteArray();
Response.ContentType = "image/jpeg";
Response.BinaryWrite(buffer);
Response.End();

--
Matt Berther
http://www.mattberther.com
I'm getting an array of bytes returned from a web service representing
a jpeg image. How can I display this on an asp.net page? The Image
control seems only to take an URL as a paremeter.

Olav



Nov 18 '05 #5
Hello Olav,

In this scenario, your implementation would be similar to what I discussed
below...

The differences: When you get your data from the web service, loop through
your images and add each to the Cache.

HttpContext.Current.Cache.Add(key, value....);

Then in your getphoto.aspx file do what I detailed below changing the first
line to be:

byte[] buffer = (byte[])HttpContext.Current.Cache[Request.QueryString[key]];

Of course, I have no error checking in there. I'll leave it up to you to
implement checking whether or not there actually is an item in the cache.

Hope this leads you down the right direction... If not, please feel free
to post a follow-up...

--
Matt Berther
http://www.mattberther.com
I have seen applications doing something like this:

getphoto.aspx?key=B59273C3BB30A9AD7AD5

Instead of using the web service to transfer the byte array back to
the client, it generates a URL with a uniqueue key and feed that back
to the client. Then the image is fetche as you suggested dynamically
when the browser requests the URL. In addition, the key expires after
a while to keep access control to the server.

How do you implement something like this? Is it easily supported by
the .NET framework or do I have to do a lot of hand-coding for this
scenario?

Olav

"Matt Berther" <mb******@hotmail.com> wrote in message
news:OM****************@TK2MSFTNGP12.phx.gbl...
Hello Olav,

An image is going to constitue another request, so what you'll need
do is assign the Image URL to a page or handler in your website.
This page/handler will have code something like this:

byte[] buffer = someMethodToGetTheByteArray();
Response.ContentType = "image/jpeg";
Response.BinaryWrite(buffer);
Response.End();
--
Matt Berther
http://www.mattberther.com
I'm getting an array of bytes returned from a web service
representing a jpeg image. How can I display this on an asp.net
page? The Image control seems only to take an URL as a paremeter.

Olav

Nov 18 '05 #6
Got it working using a Url with a key into the cache.

Thanks!

Olav

"Matt Berther" <mb******@hotmail.com> wrote in message
news:eU*************@TK2MSFTNGP11.phx.gbl...
Hello Olav,

In this scenario, your implementation would be similar to what I discussed
below...

The differences: When you get your data from the web service, loop through
your images and add each to the Cache.

HttpContext.Current.Cache.Add(key, value....);

Then in your getphoto.aspx file do what I detailed below changing the
first line to be:

byte[] buffer =
(byte[])HttpContext.Current.Cache[Request.QueryString[key]];

Of course, I have no error checking in there. I'll leave it up to you to
implement checking whether or not there actually is an item in the cache.

Hope this leads you down the right direction... If not, please feel free
to post a follow-up...

--
Matt Berther
http://www.mattberther.com
I have seen applications doing something like this:

getphoto.aspx?key=B59273C3BB30A9AD7AD5

Instead of using the web service to transfer the byte array back to
the client, it generates a URL with a uniqueue key and feed that back
to the client. Then the image is fetche as you suggested dynamically
when the browser requests the URL. In addition, the key expires after
a while to keep access control to the server.

How do you implement something like this? Is it easily supported by
the .NET framework or do I have to do a lot of hand-coding for this
scenario?

Olav

"Matt Berther" <mb******@hotmail.com> wrote in message
news:OM****************@TK2MSFTNGP12.phx.gbl...
Hello Olav,

An image is going to constitue another request, so what you'll need
do is assign the Image URL to a page or handler in your website.
This page/handler will have code something like this:

byte[] buffer = someMethodToGetTheByteArray();
Response.ContentType = "image/jpeg";
Response.BinaryWrite(buffer);
Response.End();
--
Matt Berther
http://www.mattberther.com
I'm getting an array of bytes returned from a web service
representing a jpeg image. How can I display this on an asp.net
page? The Image control seems only to take an URL as a paremeter.

Olav


Nov 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: StepH | last post by:
Hi, I'm building a little application, which the goal is to: 1./ Collect data via Serial line and or via a file (for playback). 2./ Display these data as graph, oscilloscope, ... How manage...
1
by: Alex Li | last post by:
Dear js/xmlhttp experts, I spent hours but could not solve this problem and hope someone could give me a clue: a onclick event will invoke a function to do a few things: 1. make a hidden DIV...
4
by: Axel Dahmen | last post by:
Hi, current browsers don't support "display: inline-block;" and "display: inline-table;", resp. Thus I'm using "float: left;" to achieve a similar effect. Problem is that if a row of elements...
5
by: PJ6 | last post by:
When I call this function (I verified that I'm actually getting an element with the id), why does IE ignore my attempt to set the display to none? <script> function test(id) { elem =...
13
by: Gunnar | last post by:
Hello, I am running into problems with a simple function which should change the style.display properties from 'block' to 'none'. I am able to change them from 'none' to 'block' as expected. ...
15
by: Markus Ernst | last post by:
Hi When toggling an element on and off by setting its display property via DOM access, display:none is valid for all kinds of elements, but I can't find anything about a generic value for...
5
by: libsfan01 | last post by:
function switch_display(switchme) { var el = document.getElementById(switchme); el.style.display = (el.style.display == 'none')? '' : 'none'; } im using this function to switch the display on...
2
by: Steve Richter | last post by:
I would like to use display:inline and other CSS attributes to build an entry form. Where the heading to the left of the text box is always a set width. It is not working so I am experimenting...
10
by: dkyadav80 | last post by:
<html> /// here what shoud be java script for: ->when script run then not display all input text field only display selection field. ->when user select other value for institute only this...
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.