By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,781 Members | 1,387 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,781 IT Pros & Developers. It's quick & easy.

Draw Images on fly

P: n/a
Hello friends,

I have developed an application using ASP.NET and SQL Server.
Ours is a garment factory. I need to design another module in my
application.

I want to generate images on fly based on users selection(body, sleeve
etc).
Until here no problem. Coz we have only 2 types of bodies and 3 types
of sleeves and 3 types of necks. I can design static images and save in
the system and call.

But I need to give selection of color to the user. Which color user has
selected, the image should display in that color.

Here I am strucked. So the solution is to generate images on fly as we
cant edit static images. Is there any other solution or any software
can edit the images at run time(especially color)?

Or can anyone suggest an idea?

Not ony in ASP.NET, any other also appreciated.

thanks in advance

Jun 22 '06 #1
Share this Question
Share on Google+
10 Replies


P: n/a
You can use the System.Drawing namespace and draw an image in memory in an
ASPX page, and then write it to the Response.OutputStream. You have to use
the URL of the ASPX page as an image URL, and set the Response.ContentType
to "image/jpg" (or "image.gif", depending), and it will display in another
page as if it were an image.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

I recycle.
I send everything back to the planet it came from.

<mr************@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
Hello friends,

I have developed an application using ASP.NET and SQL Server.
Ours is a garment factory. I need to design another module in my
application.

I want to generate images on fly based on users selection(body, sleeve
etc).
Until here no problem. Coz we have only 2 types of bodies and 3 types
of sleeves and 3 types of necks. I can design static images and save in
the system and call.

But I need to give selection of color to the user. Which color user has
selected, the image should display in that color.

Here I am strucked. So the solution is to generate images on fly as we
cant edit static images. Is there any other solution or any software
can edit the images at run time(especially color)?

Or can anyone suggest an idea?

Not ony in ASP.NET, any other also appreciated.

thanks in advance

Jun 22 '06 #2

P: n/a
I would strongly consider making something like this in Flash, and assign
colors programmatically using Actionscript. You can do this with various
bitmap drawing things using other web technologies, but Flash will be
easier.

-KF

<mr************@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
Hello friends,

I have developed an application using ASP.NET and SQL Server.
Ours is a garment factory. I need to design another module in my
application.

I want to generate images on fly based on users selection(body, sleeve
etc).
Until here no problem. Coz we have only 2 types of bodies and 3 types
of sleeves and 3 types of necks. I can design static images and save in
the system and call.

But I need to give selection of color to the user. Which color user has
selected, the image should display in that color.

Here I am strucked. So the solution is to generate images on fly as we
cant edit static images. Is there any other solution or any software
can edit the images at run time(especially color)?

Or can anyone suggest an idea?

Not ony in ASP.NET, any other also appreciated.

thanks in advance

Jun 22 '06 #3

P: n/a
HI kevin:
I'm Chinese people,
yes, i have meet the extend problem

when i using Resoponse.OutStream to display a image in an ascx , and
the ascx be using in the man page.

but there a problem, when i click the button in the main page to drawing
the image in the ascx controls,
and display it,the image is shown but the main page's contenttype turn to
"image/jepg" and the button is can not find in the man page.
can you tell me ,what can let the ascx content-type not to changed the main
page contenttype.
my english is pool thanks.

if you need the source code i can pulish to you .
"Kevin Spencer" <uc*@ftc.gov> 写入消息新闻:uQ**************@TK2MSFTNGP04.phx.gbl ...
You can use the System.Drawing namespace and draw an image in memory in an
ASPX page, and then write it to the Response.OutputStream. You have to use
the URL of the ASPX page as an image URL, and set the Response.ContentType
to "image/jpg" (or "image.gif", depending), and it will display in another
page as if it were an image.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

I recycle.
I send everything back to the planet it came from.

<mr************@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
Hello friends,

I have developed an application using ASP.NET and SQL Server.
Ours is a garment factory. I need to design another module in my
application.

I want to generate images on fly based on users selection(body, sleeve
etc).
Until here no problem. Coz we have only 2 types of bodies and 3 types
of sleeves and 3 types of necks. I can design static images and save in
the system and call.

But I need to give selection of color to the user. Which color user has
selected, the image should display in that color.

Here I am strucked. So the solution is to generate images on fly as we
cant edit static images. Is there any other solution or any software
can edit the images at run time(especially color)?

Or can anyone suggest an idea?

Not ony in ASP.NET, any other also appreciated.

thanks in advance


Jun 22 '06 #4

P: n/a
> HI kevin拢潞
I'm Chinese people,
yes, i have meet the extend problem

when i using Resoponse.OutStream to display a image in an ascx , and
the ascx be using in the man page.

but there a problem, when i click the button in the main page to drawing
the image in the ascx controls,
and display it,the image is shown but the main page's contenttype turn to
"image/jepg" and the button is can not find in the man page.
can you tell me ,what can let the ascx content-type not to changed the main
page contenttype.
my english is pool thanks.

if you need the source code i can pulish to you .


You can not draw the image in the same request as the rest of the page!
The page should output HTML that contains a tag like
<img src="theimage.aspx">
In the separate "theimage.aspx" you set the content-type ("image/jpeg")
and use Response.OutputStream or Response.BinaryWrite to write
the image.
The browser always uses a separate request to get the image, after it
has gotten the page HTML.

Hans Kesting
Jun 22 '06 #5

P: n/a
Thank you very much.
yes you give me a good idea,i think i can come true the project target .
thank you.

"Hans Kesting" <ne***********@spamgourmet.com> 写入消息新闻:mn***********************@spamgourmet .com...
HI kevin£o
I'm Chinese people,
yes, i have meet the extend problem

when i using Resoponse.OutStream to display a image in an ascx , and
the ascx be using in the man page.

but there a problem, when i click the button in the main page to
drawing the image in the ascx controls,
and display it,the image is shown but the main page's contenttype turn to
"image/jepg" and the button is can not find in the man page.
can you tell me ,what can let the ascx content-type not to changed the
main page contenttype.
my english is pool thanks.

if you need the source code i can pulish to you .


You can not draw the image in the same request as the rest of the page!
The page should output HTML that contains a tag like
<img src="theimage.aspx">
In the separate "theimage.aspx" you set the content-type ("image/jpeg")
and use Response.OutputStream or Response.BinaryWrite to write
the image.
The browser always uses a separate request to get the image, after it has
gotten the page HTML.

Hans Kesting

Jun 22 '06 #6

P: n/a
Hello,

Thanx for the reply. I used system.drawing namespace. I got
everything what I expected but how can I mirror the generated image.

Because, i have designed half of the shirt (right side). The mirror is
the left side. If I use bitmap.rotateFlip(rotate180flipx), actual image
is getting rotated. I want to duplicate the actual image and rotate it
and display as complete image. I think you got what I mean.

How can I do this.

My bitmap area is (200,200). I generated the image from the
middle(100,0)

Please reply me.

Kevin Spencer wrote:
You can use the System.Drawing namespace and draw an image in memory in an
ASPX page, and then write it to the Response.OutputStream. You have to use
the URL of the ASPX page as an image URL, and set the Response.ContentType
to "image/jpg" (or "image.gif", depending), and it will display in another
page as if it were an image.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

I recycle.
I send everything back to the planet it came from.

<mr************@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
Hello friends,

I have developed an application using ASP.NET and SQL Server.
Ours is a garment factory. I need to design another module in my
application.

I want to generate images on fly based on users selection(body, sleeve
etc).
Until here no problem. Coz we have only 2 types of bodies and 3 types
of sleeves and 3 types of necks. I can design static images and save in
the system and call.

But I need to give selection of color to the user. Which color user has
selected, the image should display in that color.

Here I am strucked. So the solution is to generate images on fly as we
cant edit static images. Is there any other solution or any software
can edit the images at run time(especially color)?

Or can anyone suggest an idea?

Not ony in ASP.NET, any other also appreciated.

thanks in advance


Jun 22 '06 #7

P: n/a
I'm sure your english is better than my Chinese! :)

I am not sure what all of the problems are with your solution, but I do know
of at least one, and if we eliminate them one by one we can straighten
everything out. The biggest problem is that you are attempting to insert an
image directly into a page.

An HTML document is pure text. There is no binary content in it, no images,
no Flash, no sound. These are referenced in the HTML document with tags that
contain the URL of the resource to be displayed in the browser. If you look
at the source code of any HTML page in your browser you will see this.
ASP.Net is simply a technology that, for the most part, creates HTML pages
from server-side programming. It has some other related capabilities as
well, such as the ability to send binary data from the server in an HTTP
stream.

Now, my original message said to use an ASPX page, *not* an ASCX UserControl
in a page. The reason is that there has to be a resource that can be
referenced in the HTML of another page which will send the image to the
client browser when requested. When you set the Response.ContentType to
"image/jpg" you are setting the ContentType header for the *entire*
response, which tells the browser that "xyz.aspx" is not an ASPX page, but
an image. This is *all* that the "image" ASPX page should do. Set the
Response.ContentType to "image/jpg" and write the binary image to the
Response.OutputStream. In *another* ASPX page, or even an HTML page, an HTML
image tag can be used to reference the "image" ASPX page as an image, such
as:

<img src="imageMaker.aspx" />

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

I recycle.
I send everything back to the planet it came from.

"Yankee.zhang" <ya*****@163.com> wrote in message
news:uY**************@TK2MSFTNGP04.phx.gbl...
HI kevin:
I'm Chinese people,
yes, i have meet the extend problem

when i using Resoponse.OutStream to display a image in an ascx , and
the ascx be using in the man page.

but there a problem, when i click the button in the main page to
drawing the image in the ascx controls,
and display it,the image is shown but the main page's contenttype turn to
"image/jepg" and the button is can not find in the man page.
can you tell me ,what can let the ascx content-type not to changed the
main page contenttype.
my english is pool thanks.

if you need the source code i can pulish to you .
"Kevin Spencer" <uc*@ftc.gov>
写入消息新闻:uQ**************@TK2MSFTNGP04.phx.gbl ...
You can use the System.Drawing namespace and draw an image in memory in
an ASPX page, and then write it to the Response.OutputStream. You have to
use the URL of the ASPX page as an image URL, and set the
Response.ContentType to "image/jpg" (or "image.gif", depending), and it
will display in another page as if it were an image.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

I recycle.
I send everything back to the planet it came from.

<mr************@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
Hello friends,

I have developed an application using ASP.NET and SQL Server.
Ours is a garment factory. I need to design another module in my
application.

I want to generate images on fly based on users selection(body, sleeve
etc).
Until here no problem. Coz we have only 2 types of bodies and 3 types
of sleeves and 3 types of necks. I can design static images and save in
the system and call.

But I need to give selection of color to the user. Which color user has
selected, the image should display in that color.

Here I am strucked. So the solution is to generate images on fly as we
cant edit static images. Is there any other solution or any software
can edit the images at run time(especially color)?

Or can anyone suggest an idea?

Not ony in ASP.NET, any other also appreciated.

thanks in advance



Jun 22 '06 #8

P: n/a
Copy the image to a new in-memory image, and flip the new image, then draw
it into the blank portion of the first image. :)

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

I recycle.
I send everything back to the planet it came from.

<mr************@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
Hello,

Thanx for the reply. I used system.drawing namespace. I got
everything what I expected but how can I mirror the generated image.

Because, i have designed half of the shirt (right side). The mirror is
the left side. If I use bitmap.rotateFlip(rotate180flipx), actual image
is getting rotated. I want to duplicate the actual image and rotate it
and display as complete image. I think you got what I mean.

How can I do this.

My bitmap area is (200,200). I generated the image from the
middle(100,0)

Please reply me.

Kevin Spencer wrote:
You can use the System.Drawing namespace and draw an image in memory in
an
ASPX page, and then write it to the Response.OutputStream. You have to
use
the URL of the ASPX page as an image URL, and set the
Response.ContentType
to "image/jpg" (or "image.gif", depending), and it will display in
another
page as if it were an image.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

I recycle.
I send everything back to the planet it came from.

<mr************@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
> Hello friends,
>
> I have developed an application using ASP.NET and SQL Server.
> Ours is a garment factory. I need to design another module in my
> application.
>
> I want to generate images on fly based on users selection(body, sleeve
> etc).
> Until here no problem. Coz we have only 2 types of bodies and 3 types
> of sleeves and 3 types of necks. I can design static images and save in
> the system and call.
>
> But I need to give selection of color to the user. Which color user has
> selected, the image should display in that color.
>
> Here I am strucked. So the solution is to generate images on fly as we
> cant edit static images. Is there any other solution or any software
> can edit the images at run time(especially color)?
>
> Or can anyone suggest an idea?
>
> Not ony in ASP.NET, any other also appreciated.
>
> thanks in advance
>

Jun 22 '06 #9

P: n/a
Hi Kevin,
At first thanks for your sense of humor reply.

yes, yours suggestion be using in my projects.
the aim of using ascx is i went to create a control to drawing the
image by customize datasource.

if you have any good idea for build the darw image control,please tech
me,thanks.

"Kevin Spencer" <uc*@ftc.gov> 写入消息新闻:uh**************@TK2MSFTNGP05.phx.gbl ...
I'm sure your english is better than my Chinese! :)

I am not sure what all of the problems are with your solution, but I do
know of at least one, and if we eliminate them one by one we can
straighten everything out. The biggest problem is that you are attempting
to insert an image directly into a page.

An HTML document is pure text. There is no binary content in it, no
images, no Flash, no sound. These are referenced in the HTML document with
tags that contain the URL of the resource to be displayed in the browser.
If you look at the source code of any HTML page in your browser you will
see this. ASP.Net is simply a technology that, for the most part, creates
HTML pages from server-side programming. It has some other related
capabilities as well, such as the ability to send binary data from the
server in an HTTP stream.

Now, my original message said to use an ASPX page, *not* an ASCX
UserControl in a page. The reason is that there has to be a resource that
can be referenced in the HTML of another page which will send the image to
the client browser when requested. When you set the Response.ContentType
to "image/jpg" you are setting the ContentType header for the *entire*
response, which tells the browser that "xyz.aspx" is not an ASPX page, but
an image. This is *all* that the "image" ASPX page should do. Set the
Response.ContentType to "image/jpg" and write the binary image to the
Response.OutputStream. In *another* ASPX page, or even an HTML page, an
HTML image tag can be used to reference the "image" ASPX page as an image,
such as:

<img src="imageMaker.aspx" />

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

I recycle.
I send everything back to the planet it came from.

"Yankee.zhang" <ya*****@163.com> wrote in message
news:uY**************@TK2MSFTNGP04.phx.gbl...
HI kevin:
I'm Chinese people,
yes, i have meet the extend problem

when i using Resoponse.OutStream to display a image in an ascx , and
the ascx be using in the man page.

but there a problem, when i click the button in the main page to
drawing the image in the ascx controls,
and display it,the image is shown but the main page's contenttype turn to
"image/jepg" and the button is can not find in the man page.
can you tell me ,what can let the ascx content-type not to changed the
main page contenttype.
my english is pool thanks.

if you need the source code i can pulish to you .
"Kevin Spencer" <uc*@ftc.gov> 写入消息新闻:uQ**************@TK2MSFTNGP04.phx.gbl ...
You can use the System.Drawing namespace and draw an image in memory in
an ASPX page, and then write it to the Response.OutputStream. You have
to use the URL of the ASPX page as an image URL, and set the
Response.ContentType to "image/jpg" (or "image.gif", depending), and it
will display in another page as if it were an image.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

I recycle.
I send everything back to the planet it came from.

<mr************@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
Hello friends,

I have developed an application using ASP.NET and SQL Server.
Ours is a garment factory. I need to design another module in my
application.

I want to generate images on fly based on users selection(body, sleeve
etc).
Until here no problem. Coz we have only 2 types of bodies and 3 types
of sleeves and 3 types of necks. I can design static images and save in
the system and call.

But I need to give selection of color to the user. Which color user has
selected, the image should display in that color.

Here I am strucked. So the solution is to generate images on fly as we
cant edit static images. Is there any other solution or any software
can edit the images at run time(especially color)?

Or can anyone suggest an idea?

Not ony in ASP.NET, any other also appreciated.

thanks in advance



Jun 23 '06 #10

P: n/a
Hi,

Thanx for the reply. Can you pls suggest me how to copy an image
in-memry? I used oBmp.clone() but i cant get success.

thanx
Kevin Spencer wrote:
Copy the image to a new in-memory image, and flip the new image, then draw
it into the blank portion of the first image. :)

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

I recycle.
I send everything back to the planet it came from.

<mr************@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
Hello,

Thanx for the reply. I used system.drawing namespace. I got
everything what I expected but how can I mirror the generated image.

Because, i have designed half of the shirt (right side). The mirror is
the left side. If I use bitmap.rotateFlip(rotate180flipx), actual image
is getting rotated. I want to duplicate the actual image and rotate it
and display as complete image. I think you got what I mean.

How can I do this.

My bitmap area is (200,200). I generated the image from the
middle(100,0)

Please reply me.

Kevin Spencer wrote:
You can use the System.Drawing namespace and draw an image in memory in
an
ASPX page, and then write it to the Response.OutputStream. You have to
use
the URL of the ASPX page as an image URL, and set the
Response.ContentType
to "image/jpg" (or "image.gif", depending), and it will display in
another
page as if it were an image.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

I recycle.
I send everything back to the planet it came from.

<mr************@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
> Hello friends,
>
> I have developed an application using ASP.NET and SQL Server.
> Ours is a garment factory. I need to design another module in my
> application.
>
> I want to generate images on fly based on users selection(body, sleeve
> etc).
> Until here no problem. Coz we have only 2 types of bodies and 3 types
> of sleeves and 3 types of necks. I can design static images and save in
> the system and call.
>
> But I need to give selection of color to the user. Which color user has
> selected, the image should display in that color.
>
> Here I am strucked. So the solution is to generate images on fly as we
> cant edit static images. Is there any other solution or any software
> can edit the images at run time(especially color)?
>
> Or can anyone suggest an idea?
>
> Not ony in ASP.NET, any other also appreciated.
>
> thanks in advance
>


Jun 24 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.