Draw Images on fly

M

mrajanikrishna

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
 
K

Kevin Spencer

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.
 
G

Guest

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
 
Y

Yankee.zhang

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 .
 
H

Hans Kesting

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
 
Y

Yankee.zhang

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

mrajanikrishna

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.
 
K

Kevin Spencer

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.
 
K

Kevin Spencer

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.
 
Y

Yankee.zhang

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.
 
M

mrajanikrishna

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
 

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,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top