visualizing image

K

Kristof Thys

Hello,

I'm writing a ASP.net webservice wich will visualize an image, generated
by another application.
The generated image is a char*. I can transform this to a String*, but I
want to view it as an image in my browser.
Is this possible, and how should I do this?

thx,

Kristof
 
K

Kevin Spencer

Comments inline:
I'm writing a ASP.net webservice wich will visualize an image, generated
by another application.

Visualize? A web service can return serialized data, that is, data in the
form of text. In order to "visualize" it (I will assume here that you mean
to "display") it, it would, after being returned from a Web Service, need to
be de-serialized into an image, and then displayed by the client app. So,
this part is a bit confusing.
The generated image is a char*. I can transform this to a String*, but I
want to view it as an image in my browser.

A generated image that is a pointer to type char? That isn't very helpful.
Basically, the "generated image" could be anything. The char data type in C
is the same as a byte in size, and can therefore be cast as almost anything.
Casting it as a pointer to a String would not be (necessarily) helpful
either. And again, as a Web Service, the only thing a browser will see is
XML text, not an image.

An image is not an array of char. You need to know what exactly the app is
returning if you want to make use of it. On the other hand, you could
probably write your own .Net image generator. All of the classes are there,
ready for you to use. And you would know what your app is putting out, which
is essential to working with it.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
 
K

Kristof Thys

Kevin said:
Comments inline:




Visualize? A web service can return serialized data, that is, data in the
form of text. In order to "visualize" it (I will assume here that you mean
to "display") it, it would, after being returned from a Web Service, need to
be de-serialized into an image, and then displayed by the client app. So,
this part is a bit confusing.

I'm sorry for being confusing, I've just started working and I'm new to
webservices and .NET and ASP.net. But I'll try to explain what I've got.
The objective is to view an VRML-object from a website. Not with an
VRML-viewer, but with global illumination methods.
I have an existing project (c++) to raytrace the 3D-model. It's also
possible to generate a .ppm image, in a later stage hopefully a .jpg.
The project just copies whatever is in the screenbuffer and puts it in
the .ppm.
I've created an asp.net webservice in c++ wich calls this existing
project, it gives some parameters (eg size of the image) to the project,
and at this moment the global illuminationproject just returns what it
should have put in the test.ppm. And indeed what I see in my xml is a
whole load of characters.

Suppose this load of characters is the contents of a .jpg file. Is it
possible to create an image from this data in ASP.NET?
The next step I'm planning is to create a Web Application, wich shows
the image generated.

I don't know if this is possible and how, so I thank you very much for
pointing me in the right direction.
 
K

Kevin Spencer

Thanks for the clarification, Kristof,

It sounds to me like you don't want a Web Service. If your goal is to
display the image in an ASP.Net app, then what is needed is a "vehicle" for
displaying the image in an HTML document. An HTML document is plain text,
which means that there are no binaries or images actually embedded IN the
document, but instead, there are HTML tags that indicate where images should
be downloaded from and displayed. Example:

<img src="/images/image.jpg">

This tells the browser to download the image resource from
"/images/image.jpg" and display it according to the HTML layout
characteristics of the document.

In your case, you want to create the image dynamically (programmatically).
For this task, all you need to do is to create an ASP.Net Page that either
processes the image, or calls on another app to process the image, sets the
Response.ContentType to "image/jpeg" (or whatever MIMIE type is appropriate
for that image), and writes the binary stream to the Response.OutputStream.
Then you can refer to the ASP.Net Page that streams the image in an image
tag thusly:

<img src="/someFolder/image.aspx">

If the image is in binary format and is known by you to be a stream of bytes
that is the actual image, you can just use Response.BinaryWrite() to write
the image out to the browser. If, for example, your pointer to char is a
pointer to an array of bytes, you can simply cast it as an array of bytes,
and then write it out the the browser.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,832
Latest member
GlennSmall

Latest Threads

Top