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

Generate image on the fly c#

HI guy

I am working on the web application that required to display

the chart image on the page. The process is clicking the button

and browser will popup another windows that displayed the

image. The problem is the image is not a file but a array of

bytes so that i couldn't using it's image url to display in

different browser. Is there any way to create an image on the

fly i.e. get the array of bytes and display it on the browser

Assume i have an Generate.aspx that contain the button and its

input to generate the image ie.image width, image height, an Display.aspx to
show the image

and the following method

//Returns array of bytes

private byte[] GetBinaryImage(int width,int height)

{

//Get data from database

}

This is urgent someone help me to do so please.
Thank you
Popoxinhxan

Nov 16 '05 #1
5 9995
You can create another aspx, say, GimmeDaImage.aspx, which would actually
output the image bytes and return the correct MIME type in the HTTP headers.

See docs on Response.ContentType and Response.BinaryWrite.

And your image tag would look like

<IMG SRC="GimmeDaImage.aspx?ImageID=1">

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Popoxinhxan" <Po*********@discussions.microsoft.com> wrote in message
news:D4**********************************@microsof t.com...
HI guy

I am working on the web application that required to display

the chart image on the page. The process is clicking the button

and browser will popup another windows that displayed the

image. The problem is the image is not a file but a array of

bytes so that i couldn't using it's image url to display in

different browser. Is there any way to create an image on the

fly i.e. get the array of bytes and display it on the browser

Assume i have an Generate.aspx that contain the button and its

input to generate the image ie.image width, image height, an Display.aspx
to
show the image

and the following method

//Returns array of bytes

private byte[] GetBinaryImage(int width,int height)

{

//Get data from database

}

This is urgent someone help me to do so please.
Thank you
Popoxinhxan


Nov 16 '05 #2
GimmieDaImage lol
You can create another aspx, say, GimmeDaImage.aspx, which would
actually output the image bytes and return the correct MIME type in
the HTTP headers.

See docs on Response.ContentType and Response.BinaryWrite.

And your image tag would look like

<IMG SRC="GimmeDaImage.aspx?ImageID=1">

"Popoxinhxan" <Po*********@discussions.microsoft.com> wrote in message
news:D4**********************************@microsof t.com...
HI guy

I am working on the web application that required to display

the chart image on the page. The process is clicking the button

and browser will popup another windows that displayed the

image. The problem is the image is not a file but a array of

bytes so that i couldn't using it's image url to display in

different browser. Is there any way to create an image on the

fly i.e. get the array of bytes and display it on the browser

Assume i have an Generate.aspx that contain the button and its

input to generate the image ie.image width, image height, an
Display.aspx
to
show the image
and the following method

//Returns array of bytes

private byte[] GetBinaryImage(int width,int height)

{

//Get data from database

}

This is urgent someone help me to do so please.
Thank you
Popoxinhxan


Nov 16 '05 #3


"Dmitriy Lapshin [C# / .NET MVP]" wrote:
You can create another aspx, say, GimmeDaImage.aspx, which would actually
output the image bytes and return the correct MIME type in the HTTP headers.

See docs on Response.ContentType and Response.BinaryWrite.
Yes, I've try this but it's doesn't work. Could you please give me the
specific example
Thank you
And your image tag would look like

<IMG SRC="GimmeDaImage.aspx?ImageID=1">

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Popoxinhxan" <Po*********@discussions.microsoft.com> wrote in message
news:D4**********************************@microsof t.com...
HI guy

I am working on the web application that required to display

the chart image on the page. The process is clicking the button

and browser will popup another windows that displayed the

image. The problem is the image is not a file but a array of

bytes so that i couldn't using it's image url to display in

different browser. Is there any way to create an image on the

fly i.e. get the array of bytes and display it on the browser

Assume i have an Generate.aspx that contain the button and its

input to generate the image ie.image width, image height, an Display.aspx
to
show the image

and the following method

//Returns array of bytes

private byte[] GetBinaryImage(int width,int height)

{

//Get data from database

}

This is urgent someone help me to do so please.
Thank you
Popoxinhxan


Nov 16 '05 #4
Mind the line wraps:

http://groups-beta.google.com/group/...9c8d3397488915 -
contains a reply from someone at Microsoft!

http://groups-beta.google.com/group/...af7b762dfdb6bc

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Popoxinhxan" <Po*********@discussions.microsoft.com> wrote in message
news:07**********************************@microsof t.com...


"Dmitriy Lapshin [C# / .NET MVP]" wrote:
You can create another aspx, say, GimmeDaImage.aspx, which would actually
output the image bytes and return the correct MIME type in the HTTP
headers.

See docs on Response.ContentType and Response.BinaryWrite.


Yes, I've try this but it's doesn't work. Could you please give me the
specific example
Thank you
And your image tag would look like

<IMG SRC="GimmeDaImage.aspx?ImageID=1">

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Popoxinhxan" <Po*********@discussions.microsoft.com> wrote in message
news:D4**********************************@microsof t.com...
> HI guy
>
>
>
> I am working on the web application that required to display
>
> the chart image on the page. The process is clicking the button
>
> and browser will popup another windows that displayed the
>
> image. The problem is the image is not a file but a array of
>
> bytes so that i couldn't using it's image url to display in
>
> different browser. Is there any way to create an image on the
>
> fly i.e. get the array of bytes and display it on the browser
>
> Assume i have an Generate.aspx that contain the button and its
>
> input to generate the image ie.image width, image height, an
> Display.aspx
> to
> show the image
>
> and the following method
>
>
>
> //Returns array of bytes
>
> private byte[] GetBinaryImage(int width,int height)
>
> {
>
> //Get data from database
>
> }
>
> This is urgent someone help me to do so please.
> Thank you
> Popoxinhxan
>



Nov 16 '05 #5
Ski
Heres the steps i do it in

create an aspx page that calls your image draw routing in its page load
event

write a function that draws your image onto a bitmap

use bitmap.save to output your image to a stream. Use
Response.OutputStream as this stream.

for example
private void Page_Load(object sender, System.EventArgs e)
{
//initialise etc first

Renderer.RenderToStream(Response.OutputStream);
}

in my renderer class

Public void RenderToStream(Stream target)
{
//---
//do all your drawing
//---

//then to send back a jpg

EncoderParameters encoderParams = new EncoderParameters();
long[] quality = new long[1];
quality[0] = 99;

EncoderParameter encoderParam = new EncoderParameter(Encoder.Quality,
quality);
encoderParams.Param[0] = encoderParam;
ImageCodecInfo[] arrayICI = ImageCodecInfo.GetImageEncoders();
ImageCodecInfo jpegICI = null;

for (int x = 0; x < arrayICI.Length; x++)
{
if (arrayICI[x].FormatDescription.Equals("JPEG"))
{
jpegICI = arrayICI[x];
break;
}
}

if (jpegICI != null)
{
bm.Save(target, jpegICI, encoderParams);
}

//clean up everything here

}
call this from another page (programatically) like

picDial.ImageUrl=@"dial.aspx?ID=1&VALUE="+sValue+" &TYPE="+sType+"&TITLE="+sTitle;


http://darkhold.aspxconnection.com/Default.aspx

for the end result of what ive done.

hth
Scott

Popoxinhxan wrote:
HI guy

I am working on the web application that required to display

the chart image on the page. The process is clicking the button

and browser will popup another windows that displayed the

image. The problem is the image is not a file but a array of

bytes so that i couldn't using it's image url to display in

different browser. Is there any way to create an image on the

fly i.e. get the array of bytes and display it on the browser

Assume i have an Generate.aspx that contain the button and its

input to generate the image ie.image width, image height, an Display.aspx to
show the image

and the following method

//Returns array of bytes

private byte[] GetBinaryImage(int width,int height)

{

//Get data from database

}

This is urgent someone help me to do so please.
Thank you
Popoxinhxan

Nov 17 '05 #6

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

Similar topics

4
by: Lukasz Indyk | last post by:
i want to convert html to image (format of the image does not matter). is it possible in python? or mayby it is possible to convert html first to the postscript, and then postscript to image?
4
by: Karthik Seetharaman | last post by:
I have to aspx pages default.aspx and imagegen.aspx default.aspx has an image webcontrol whose imageurl property is set to imagegen.aspx. imagegen.aspx generates a bitmap image and writes it to...
0
by: Chad A. Beckner | last post by:
Hey all, I know I've seen this code out there, just can't remember where. I want to generate an image of a webpage using ASP .NET. Kind of like Microsoft does with their search companion. ...
3
by: Rajiv Das | last post by:
C# 2.0 XP SP2 In My Code, I am using HttpWebRequest to visit a particular URL. I am required to generate a snapshot image (if this request were made through say IE) and save as jpeg. About .1...
0
by: ptkumar | last post by:
Hi All, I am using JfreeCharts. I have to generate an image(Pie Graph) in a jsp file. That jsp file image should be display into an .xls file. please help me on this. kumar
4
by: ameyas | last post by:
hi all, i am using an image which has image map and i provide the href action url. i have provided the url to open a pop up window like "javascript:window.open('www.google.com');" but on...
1
by: rekhaiwaves | last post by:
Hi, My Application needs to generate image from an integer array. I receive the image as stream, 1) i convert it into byte array 2) Then Convert the byte array to integer array and store...
0
by: Tem | last post by:
I need to draw a black circle using WPF and generate an image file. I used the following but it resulted in a blank file. I cannot figure out what is wrong with it. Thanks, Tem ...
2
by: nvinhphu | last post by:
Dear all, I would like to generate images like the ones in the right column at this link http://www.micthemodel.org/pages/examples.html (Sorry but I can not post attachment). These images...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.