Scaling image with FXRuby

T

Thomas Leitner

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
 
S

Sander Jansen

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
 

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,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top