473,804 Members | 3,725 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 10030
You can create another aspx, say, GimmeDaImage.as px, which would actually
output the image bytes and return the correct MIME type in the HTTP headers.

See docs on Response.Conten tType and Response.Binary Write.

And your image tag would look like

<IMG SRC="GimmeDaIma ge.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

"Popoxinhxa n" <Po*********@di scussions.micro soft.com> wrote in message
news:D4******** *************** ***********@mic rosoft.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.as px, which would
actually output the image bytes and return the correct MIME type in
the HTTP headers.

See docs on Response.Conten tType and Response.Binary Write.

And your image tag would look like

<IMG SRC="GimmeDaIma ge.aspx?ImageID =1">

"Popoxinhxa n" <Po*********@di scussions.micro soft.com> wrote in message
news:D4******** *************** ***********@mic rosoft.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.as px, which would actually
output the image bytes and return the correct MIME type in the HTTP headers.

See docs on Response.Conten tType and Response.Binary Write.
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="GimmeDaIma ge.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

"Popoxinhxa n" <Po*********@di scussions.micro soft.com> wrote in message
news:D4******** *************** ***********@mic rosoft.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

"Popoxinhxa n" <Po*********@di scussions.micro soft.com> wrote in message
news:07******** *************** ***********@mic rosoft.com...


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

See docs on Response.Conten tType and Response.Binary Write.


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="GimmeDaIma ge.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

"Popoxinhxa n" <Po*********@di scussions.micro soft.com> wrote in message
news:D4******** *************** ***********@mic rosoft.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.Output Stream as this stream.

for example
private void Page_Load(objec t sender, System.EventArg s e)
{
//initialise etc first

Renderer.Render ToStream(Respon se.OutputStream );
}

in my renderer class

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

//then to send back a jpg

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

EncoderParamete r encoderParam = new EncoderParamete r(Encoder.Quali ty,
quality);
encoderParams.P aram[0] = encoderParam;
ImageCodecInfo[] arrayICI = ImageCodecInfo. GetImageEncoder s();
ImageCodecInfo jpegICI = null;

for (int x = 0; x < arrayICI.Length ; x++)
{
if (arrayICI[x].FormatDescript ion.Equals("JPE G"))
{
jpegICI = arrayICI[x];
break;
}
}

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

//clean up everything here

}
call this from another page (programaticall y) like

picDial.ImageUr l=@"dial.aspx?I D=1&VALUE="+sVa lue+"&TYPE="+sT ype+"&TITLE="+s Title;


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
3967
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
6081
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 outputstream and this image is then displayed in default.aspx Now i would like to generate a map for this image so i can have different regions of the image hyperlink to some urls. How to accomplish this ?
0
986
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. Does anyone have any ideas? Thanks! Chad
3
1192
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 million such requests are made in a cycle. What's the possible solution ?
0
1705
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
5169
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 clicking the image, the page (main window) gets refreshed in the background the pop up opens as desired. is there a way to cancel the refreshing of page ? i tried
1
992
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 it in the Database.
0
1176
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 RenderTargetBitmap rtb = new RenderTargetBitmap(200, 200, 96, 96, PixelFormats.Pbgra32);
2
2756
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 are in fact 2D slices of a 3D image of a cube containing a set
0
9706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9579
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10330
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10319
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10076
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9144
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6851
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5520
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.