Newbie: Image button aspect ratio

Discussion in 'ASP .Net' started by =?Utf-8?B?RGF2aWQgV2hpdGNodXJjaC1CZW5uZXR0?=, Nov 6, 2004.

  1. I have some image buttons which I am dynamically adding from a database. No
    problems so far...

    However, when it loads the image using IMAGEURL=, it doesn't keep the
    original aspect ratio.

    Is there a way to keep this without resizing the control?

    Many thanks,

    David Whitchurch-Bennett
     
    =?Utf-8?B?RGF2aWQgV2hpdGNodXJjaC1CZW5uZXR0?=, Nov 6, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?RGF2aWQgV2hpdGNodXJjaC1CZW5uZXR0?=

    Scott M. Guest

    The aspect ratio is not affected at all by the ImageURL property. Most
    likely you have the height or width of the control set to a value. If you
    remove those values from the control, the image will come in at its normal
    size, if you want it smaller (but wish to preserve the aspect ratio), then
    just set a width or a height for the control but not both.

    "David Whitchurch-Bennett"
    <> wrote in message
    news:...
    >I have some image buttons which I am dynamically adding from a database. No
    > problems so far...
    >
    > However, when it loads the image using IMAGEURL=, it doesn't keep the
    > original aspect ratio.
    >
    > Is there a way to keep this without resizing the control?
    >
    > Many thanks,
    >
    > David Whitchurch-Bennett
    >
     
    Scott M., Nov 6, 2004
    #2
    1. Advertising

  3. Thanks for that information. What I have in my app is an image button set to
    250 x 250, with a thick border which is all part of the visual theme. That is
    why I have set the size first. What I want to do is load an image dynamically
    in the center of the image button, but keep the image button border the same
    size, so the visual theme is preserved.

    Is this possible, or will the only way be to place the image button into
    another container with a border.

    "Scott M." wrote:

    > The aspect ratio is not affected at all by the ImageURL property. Most
    > likely you have the height or width of the control set to a value. If you
    > remove those values from the control, the image will come in at its normal
    > size, if you want it smaller (but wish to preserve the aspect ratio), then
    > just set a width or a height for the control but not both.
    >
    > "David Whitchurch-Bennett"
    > <> wrote in message
    > news:...
    > >I have some image buttons which I am dynamically adding from a database. No
    > > problems so far...
    > >
    > > However, when it loads the image using IMAGEURL=, it doesn't keep the
    > > original aspect ratio.
    > >
    > > Is there a way to keep this without resizing the control?
    > >
    > > Many thanks,
    > >
    > > David Whitchurch-Bennett
    > >

    >
    >
    >
     
    =?Utf-8?B?RGF2aWQgV2hpdGNodXJjaC1CZW5uZXR0?=, Nov 7, 2004
    #3
  4. =?Utf-8?B?RGF2aWQgV2hpdGNodXJjaC1CZW5uZXR0?=

    Scott M. Guest

    I think this is more of an issue of having graphics that will fit into a
    250x250 space that VS.NET sizing the images for you. Your best bet is to
    use a good graphics tool to create images that will fit into that space,
    rather than attempt to have VS.NET fit them for you.

    "David Whitchurch-Bennett"
    <> wrote in message
    news:...
    > Thanks for that information. What I have in my app is an image button set
    > to
    > 250 x 250, with a thick border which is all part of the visual theme. That
    > is
    > why I have set the size first. What I want to do is load an image
    > dynamically
    > in the center of the image button, but keep the image button border the
    > same
    > size, so the visual theme is preserved.
    >
    > Is this possible, or will the only way be to place the image button into
    > another container with a border.
    >
    > "Scott M." wrote:
    >
    >> The aspect ratio is not affected at all by the ImageURL property. Most
    >> likely you have the height or width of the control set to a value. If
    >> you
    >> remove those values from the control, the image will come in at its
    >> normal
    >> size, if you want it smaller (but wish to preserve the aspect ratio),
    >> then
    >> just set a width or a height for the control but not both.
    >>
    >> "David Whitchurch-Bennett"
    >> <> wrote in message
    >> news:...
    >> >I have some image buttons which I am dynamically adding from a database.
    >> >No
    >> > problems so far...
    >> >
    >> > However, when it loads the image using IMAGEURL=, it doesn't keep the
    >> > original aspect ratio.
    >> >
    >> > Is there a way to keep this without resizing the control?
    >> >
    >> > Many thanks,
    >> >
    >> > David Whitchurch-Bennett
    >> >

    >>
    >>
    >>
     
    Scott M., Nov 7, 2004
    #4
  5. I already have this. I am using a class that I have written to scale down the
    image first for two reasons.

    1. To help the page load faster.
    2. To prevent people downloading the full size images (photographic website).

    Rather than resizing all of my photos, my class takes care of this by
    scaling down the image. I pass the maximum width and height, and the image is
    scaled down to fit and it maintains the aspect ratio.

    When I put the scaled down image into the button, it stetches it out to fit
    in both dimensions.

    I guess I just asumed there would be a way to display the image without
    stretching it out. I can pad the extra pixels in the function to return a
    square image if that is a better way.

    Thanks for your help. ASP.NET is quite different to what I am used to, but I
    am getting there!

    "Scott M." wrote:

    > I think this is more of an issue of having graphics that will fit into a
    > 250x250 space that VS.NET sizing the images for you. Your best bet is to
    > use a good graphics tool to create images that will fit into that space,
    > rather than attempt to have VS.NET fit them for you.
    >
    > "David Whitchurch-Bennett"
    > <> wrote in message
    > news:...
    > > Thanks for that information. What I have in my app is an image button set
    > > to
    > > 250 x 250, with a thick border which is all part of the visual theme. That
    > > is
    > > why I have set the size first. What I want to do is load an image
    > > dynamically
    > > in the center of the image button, but keep the image button border the
    > > same
    > > size, so the visual theme is preserved.
    > >
    > > Is this possible, or will the only way be to place the image button into
    > > another container with a border.
    > >
    > > "Scott M." wrote:
    > >
    > >> The aspect ratio is not affected at all by the ImageURL property. Most
    > >> likely you have the height or width of the control set to a value. If
    > >> you
    > >> remove those values from the control, the image will come in at its
    > >> normal
    > >> size, if you want it smaller (but wish to preserve the aspect ratio),
    > >> then
    > >> just set a width or a height for the control but not both.
    > >>
    > >> "David Whitchurch-Bennett"
    > >> <> wrote in message
    > >> news:...
    > >> >I have some image buttons which I am dynamically adding from a database.
    > >> >No
    > >> > problems so far...
    > >> >
    > >> > However, when it loads the image using IMAGEURL=, it doesn't keep the
    > >> > original aspect ratio.
    > >> >
    > >> > Is there a way to keep this without resizing the control?
    > >> >
    > >> > Many thanks,
    > >> >
    > >> > David Whitchurch-Bennett
    > >> >
    > >>
    > >>
    > >>

    >
    >
    >
     
    =?Utf-8?B?RGF2aWQgV2hpdGNodXJjaC1CZW5uZXR0?=, Nov 7, 2004
    #5
  6. =?Utf-8?B?RGF2aWQgV2hpdGNodXJjaC1CZW5uZXR0?=

    Scott M. Guest

    How about putting the image into an image control (not a button image
    control) and overlaying the image control on top of your button control?


    "David Whitchurch-Bennett"
    <> wrote in message
    news:...
    >I already have this. I am using a class that I have written to scale down
    >the
    > image first for two reasons.
    >
    > 1. To help the page load faster.
    > 2. To prevent people downloading the full size images (photographic
    > website).
    >
    > Rather than resizing all of my photos, my class takes care of this by
    > scaling down the image. I pass the maximum width and height, and the image
    > is
    > scaled down to fit and it maintains the aspect ratio.
    >
    > When I put the scaled down image into the button, it stetches it out to
    > fit
    > in both dimensions.
    >
    > I guess I just asumed there would be a way to display the image without
    > stretching it out. I can pad the extra pixels in the function to return a
    > square image if that is a better way.
    >
    > Thanks for your help. ASP.NET is quite different to what I am used to, but
    > I
    > am getting there!
    >
    > "Scott M." wrote:
    >
    >> I think this is more of an issue of having graphics that will fit into a
    >> 250x250 space that VS.NET sizing the images for you. Your best bet is to
    >> use a good graphics tool to create images that will fit into that space,
    >> rather than attempt to have VS.NET fit them for you.
    >>
    >> "David Whitchurch-Bennett"
    >> <> wrote in message
    >> news:...
    >> > Thanks for that information. What I have in my app is an image button
    >> > set
    >> > to
    >> > 250 x 250, with a thick border which is all part of the visual theme.
    >> > That
    >> > is
    >> > why I have set the size first. What I want to do is load an image
    >> > dynamically
    >> > in the center of the image button, but keep the image button border the
    >> > same
    >> > size, so the visual theme is preserved.
    >> >
    >> > Is this possible, or will the only way be to place the image button
    >> > into
    >> > another container with a border.
    >> >
    >> > "Scott M." wrote:
    >> >
    >> >> The aspect ratio is not affected at all by the ImageURL property.
    >> >> Most
    >> >> likely you have the height or width of the control set to a value. If
    >> >> you
    >> >> remove those values from the control, the image will come in at its
    >> >> normal
    >> >> size, if you want it smaller (but wish to preserve the aspect ratio),
    >> >> then
    >> >> just set a width or a height for the control but not both.
    >> >>
    >> >> "David Whitchurch-Bennett"
    >> >> <> wrote in message
    >> >> news:...
    >> >> >I have some image buttons which I am dynamically adding from a
    >> >> >database.
    >> >> >No
    >> >> > problems so far...
    >> >> >
    >> >> > However, when it loads the image using IMAGEURL=, it doesn't keep
    >> >> > the
    >> >> > original aspect ratio.
    >> >> >
    >> >> > Is there a way to keep this without resizing the control?
    >> >> >
    >> >> > Many thanks,
    >> >> >
    >> >> > David Whitchurch-Bennett
    >> >> >
    >> >>
    >> >>
    >> >>

    >>
    >>
    >>
     
    Scott M., Nov 7, 2004
    #6
    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. Arthur Hsu
    Replies:
    5
    Views:
    5,933
    Steven Cheng[MSFT]
    Dec 8, 2004
  2. mharness
    Replies:
    0
    Views:
    432
    mharness
    Sep 28, 2006
  3. trint
    Replies:
    1
    Views:
    389
    =?Utf-8?B?UGFnZSBCcm9va3M=?=
    Apr 27, 2007
  4. David Whitchurch-Bennett

    * NEWBIE ** ImageButton Aspect Ratio

    David Whitchurch-Bennett, Nov 5, 2004, in forum: ASP General
    Replies:
    1
    Views:
    151
    Ray Costanzo [MVP]
    Nov 5, 2004
  5. Andrew Poulos

    Resizing image while maintaining aspect ratio

    Andrew Poulos, Mar 31, 2009, in forum: Javascript
    Replies:
    2
    Views:
    116
    Thomas 'PointedEars' Lahn
    Apr 1, 2009
Loading...

Share This Page