Draw Images on fly

Discussion in 'ASP .Net' started by mrajanikrishna@gmail.com, Jun 22, 2006.

  1. Guest

    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, 2006
    #1
    1. Advertising

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

    <> wrote in message
    news:...
    > 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
    >
    Kevin Spencer, Jun 22, 2006
    #2
    1. Advertising

  3. Guest 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



    <> wrote in message
    news:...
    > 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
    >
    Guest, Jun 22, 2006
    #3
  4. Yankee.zhang Guest

    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" <> дÈëÏûÏ¢ÐÂÎÅ:...
    > 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.
    >
    > <> wrote in message
    > news:...
    >> 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
    >>

    >
    >
    Yankee.zhang, Jun 22, 2006
    #4
  5. Hans Kesting Guest

    > 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
    Hans Kesting, Jun 22, 2006
    #5
  6. Yankee.zhang Guest

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

    "Hans Kesting" <> дÈëÏûÏ¢ÐÂÎÅ:...
    >> 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
    >
    >
    Yankee.zhang, Jun 22, 2006
    #6
  7. Guest

    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.
    >
    > <> wrote in message
    > news:...
    > > 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, 2006
    #7
  8. 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" <> wrote in message
    news:...
    > 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" <>
    > дÈëÏûÏ¢ÐÂÎÅ:...
    >> 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.
    >>
    >> <> wrote in message
    >> news:...
    >>> 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
    >>>

    >>
    >>

    >
    >
    Kevin Spencer, Jun 22, 2006
    #8
  9. 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.

    <> wrote in message
    news:...
    > 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.
    >>
    >> <> wrote in message
    >> news:...
    >> > 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
    >> >

    >
    Kevin Spencer, Jun 22, 2006
    #9
  10. Yankee.zhang Guest

    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" <> дÈëÏûÏ¢ÐÂÎÅ:...
    > 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" <> wrote in message
    > news:...
    >> 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" <> дÈëÏûÏ¢ÐÂÎÅ:...
    >>> 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.
    >>>
    >>> <> wrote in message
    >>> news:...
    >>>> 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
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
    Yankee.zhang, Jun 23, 2006
    #10
  11. Guest

    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.
    >
    > <> wrote in message
    > news:...
    > > 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.
    > >>
    > >> <> wrote in message
    > >> news:...
    > >> > 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, 2006
    #11
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DaveF

    animate images on the fly

    DaveF, Apr 21, 2004, in forum: ASP .Net
    Replies:
    8
    Views:
    313
    Kevin Spencer
    Apr 22, 2004
  2. Klaus Jensen

    Control to draw maps on images?

    Klaus Jensen, Oct 9, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    515
    =?Utf-8?B?SmVmZiBhdCBCZW5uZXQtVGVjLmNvbQ==?=
    Oct 15, 2005
  3. cantbprince

    Creating Thumbnail Images on the fly

    cantbprince, Apr 11, 2006, in forum: Java
    Replies:
    3
    Views:
    4,772
    Oliver Wong
    Apr 11, 2006
  4. K
    Replies:
    22
    Views:
    825
  5. Brian

    Fly outmenu on the fly

    Brian, Apr 8, 2005, in forum: Javascript
    Replies:
    0
    Views:
    86
    Brian
    Apr 8, 2005
Loading...

Share This Page