Scaling image with FXRuby

Discussion in 'Ruby' started by Thomas Leitner, Jan 17, 2005.

  1. Hy,

    I try to scale an image in FXRuby. First I create the image with

    icon = FXPNGIcon.new( getApp(), "image.png" )
    icon.create

    and then I do this

    icon.scale( 100, 100 )
    dc.drawIcon(icon, 0, 0)

    This should draw the scaled icon on the specified DeviceContext,
    however, the result is distorted.

    What I try to accomplish:
    - First load the png picture with transparent background
    - Scale the picture depending on the current window size
    - Draw the scaled image

    Is there method like drawIcon( icon, x, y, width, height) available?
    This would simply everything!

    If not: Can anyone advise me on how to do this? I could not find a
    solution...

    Thomas

    --
    |\ Thomas Leitner -- thomas [underscore] leitner [at] gmx [dot] at
    |>
    |/ "Life is what happens to you while you're busy making other plans"
     
    Thomas Leitner, Jan 17, 2005
    #1
    1. Advertising

  2. Make sure IMAGE_KEEP flag is passed when you construct a FXIcon. icon.create
    will throw away the icon data if you don't pass this flag. Scaling is done
    only on the client side. If there's no client side data, it will do a normal
    resize and the content of the image is then undefined.

    Another option is to do a create after scaling the icon.

    Hope this helps,

    Sander




    On Monday 17 January 2005 04:36 am, Thomas Leitner wrote:
    > Hy,
    >
    > I try to scale an image in FXRuby. First I create the image with
    >
    > icon = FXPNGIcon.new( getApp(), "image.png" )
    > icon.create
    >
    > and then I do this
    >
    > icon.scale( 100, 100 )
    > dc.drawIcon(icon, 0, 0)
    >
    > This should draw the scaled icon on the specified DeviceContext,
    > however, the result is distorted.
    >
    > What I try to accomplish:
    > - First load the png picture with transparent background
    > - Scale the picture depending on the current window size
    > - Draw the scaled image
    >
    > Is there method like drawIcon( icon, x, y, width, height) available?
    > This would simply everything!
    >
    > If not: Can anyone advise me on how to do this? I could not find a
    > solution...
    >
    > Thomas
     
    Sander Jansen, Feb 16, 2005
    #2
    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. Scaling PNG image

    , Apr 29, 2004, in forum: Java
    Replies:
    3
    Views:
    725
    Thomas Weidenfeller
    Apr 30, 2004
  2. Daniel L. Bateman

    Overriding browser image auto-scaling

    Daniel L. Bateman, Oct 29, 2003, in forum: HTML
    Replies:
    6
    Views:
    1,324
    Mark Parnell
    Oct 30, 2003
  3. Yofnik
    Replies:
    3
    Views:
    506
    Yofnik
    Jan 27, 2007
  4. Patrick Hurley

    FXRuby Image Scaling question

    Patrick Hurley, Feb 2, 2006, in forum: Ruby
    Replies:
    2
    Views:
    119
    Patrick Hurley
    Feb 2, 2006
  5. Lyle Johnson
    Replies:
    0
    Views:
    153
    Lyle Johnson
    May 20, 2008
Loading...

Share This Page