Set Image Control to Bitmap

Discussion in 'ASP .Net' started by MikeB, Aug 13, 2007.

  1. MikeB

    MikeB Guest

    Hello All, want to be able to pull images from the database and load them
    into a bitmap through a stream which I have working. I then want to take
    the bitmap and load it into a Image control without haveing to save the
    bitmap as a file. Is this possible? Currently, I just display the bitmap
    by calling Bitmap.save however, if users do not know to click the image they
    can not see the full size. If I can create a bitmap from the stream I know
    the size so I can set the properties of a image control and then display the
    bitmap in the image. Does this make since or am I going about this the
    wrong way? So in a nutshell, I am pulling images from a DB and want to
    display the full size without having to actuall save the image to a file.
    Any pointers?

    TIA
     
    MikeB, Aug 13, 2007
    #1
    1. Advertising

  2. You can make an mypage.aspx page that returns bitmap (not HTML)
    1. You need to set ContentType = "img/gif"; or (jpg)
    2. You need to set ContentLength to the size of the image
    3. Use Response.BinaryWrite to output the image. Or since Response is a
    Stream you can do Bitmap.Save(Response);

    in your HTML you write <img src="mypage.aspx">


    PS: It's more efficient to use handler for that task. mypage.ashx. But aspx
    will work too if you fill more comfortable with aspx.

    George.



    "MikeB" <> wrote in message
    news:...
    > Hello All, want to be able to pull images from the database and load them
    > into a bitmap through a stream which I have working. I then want to take
    > the bitmap and load it into a Image control without haveing to save the
    > bitmap as a file. Is this possible? Currently, I just display the bitmap
    > by calling Bitmap.save however, if users do not know to click the image
    > they can not see the full size. If I can create a bitmap from the stream
    > I know the size so I can set the properties of a image control and then
    > display the bitmap in the image. Does this make since or am I going about
    > this the wrong way? So in a nutshell, I am pulling images from a DB and
    > want to display the full size without having to actuall save the image to
    > a file. Any pointers?
    >
    > TIA
    >
     
    George Ter-Saakov, Aug 13, 2007
    #2
    1. Advertising

  3. Your page can have an Image control on it, and that Image control can point
    to another page (or handler) that retrieves the image.
    Here are the details:
    http://SteveOrr.net/articles/ImproveYourImages.aspx
    http://dotnetslackers.com/articles/aspnet/FileDenial.aspx

    --
    I hope this helps,
    Steve C. Orr,
    MCSD, MVP, CSM, ASPInsider
    http://SteveOrr.net



    "MikeB" <> wrote in message
    news:...
    > Hello All, want to be able to pull images from the database and load them
    > into a bitmap through a stream which I have working. I then want to take
    > the bitmap and load it into a Image control without haveing to save the
    > bitmap as a file. Is this possible? Currently, I just display the bitmap
    > by calling Bitmap.save however, if users do not know to click the image
    > they can not see the full size. If I can create a bitmap from the stream
    > I know the size so I can set the properties of a image control and then
    > display the bitmap in the image. Does this make since or am I going about
    > this the wrong way? So in a nutshell, I am pulling images from a DB and
    > want to display the full size without having to actuall save the image to
    > a file. Any pointers?
    >
    > TIA
    >
     
    Steve C. Orr [MCSD, MVP, CSM, ASP Insider], Aug 14, 2007
    #3
  4. Here is a way to do this without relying on an external handler such as
    another page:

    http://www.eggheadcafe.com/articles/20050911.asp

    -Peter
    Recursion: see Recursion
    site: http://www.eggheadcafe.com
    unBlog: http://petesbloggerama.blogspot.com
    BlogMetaFinder: http://www.blogmetafinder.com



    "MikeB" wrote:

    > Hello All, want to be able to pull images from the database and load them
    > into a bitmap through a stream which I have working. I then want to take
    > the bitmap and load it into a Image control without haveing to save the
    > bitmap as a file. Is this possible? Currently, I just display the bitmap
    > by calling Bitmap.save however, if users do not know to click the image they
    > can not see the full size. If I can create a bitmap from the stream I know
    > the size so I can set the properties of a image control and then display the
    > bitmap in the image. Does this make since or am I going about this the
    > wrong way? So in a nutshell, I am pulling images from a DB and want to
    > display the full size without having to actuall save the image to a file.
    > Any pointers?
    >
    > TIA
    >
    >
    >
     
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Aug 14, 2007
    #4
  5. MikeB

    MikeB Guest

    Thanks everyone for the replies.

    "MikeB" <> wrote in message
    news:...
    > Hello All, want to be able to pull images from the database and load them
    > into a bitmap through a stream which I have working. I then want to take
    > the bitmap and load it into a Image control without haveing to save the
    > bitmap as a file. Is this possible? Currently, I just display the bitmap
    > by calling Bitmap.save however, if users do not know to click the image
    > they can not see the full size. If I can create a bitmap from the stream
    > I know the size so I can set the properties of a image control and then
    > display the bitmap in the image. Does this make since or am I going about
    > this the wrong way? So in a nutshell, I am pulling images from a DB and
    > want to display the full size without having to actuall save the image to
    > a file. Any pointers?
    >
    > TIA
    >
     
    MikeB, Aug 15, 2007
    #5
    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. Ben

    Bitmap as a Image web control

    Ben, Jun 26, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    593
    bruce barker \(sqlwork.com\)
    Jun 26, 2006
  2. Gandalf

    Masked bitmap from bitmap

    Gandalf, Jan 29, 2004, in forum: Python
    Replies:
    0
    Views:
    594
    Gandalf
    Jan 29, 2004
  3. xqggz
    Replies:
    1
    Views:
    427
    Victor Bazarov
    Jun 19, 2007
  4. Support
    Replies:
    1
    Views:
    463
    Steve C. Orr [MVP, MCSD]
    Jun 3, 2005
  5. Beb

    Bitmap as a Image web control

    Beb, Jun 26, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    591
    Steve C. Orr [MVP, MCSD]
    Jun 27, 2006
Loading...

Share This Page