#495 FWT image widget

tactics Fri 27 Mar 2009

I'm creating a small app in Fan to interface with a web site I created for my aunt. It will upload pictures with assorted metadata to a PHP script.

I wanted to know what kind of widget is most appropriate for displaying the image. I know I can draw it onto a Pane or Widget, but I didn't know if there was a more "natural" solution.... like an existing ImageWidget by some name I haven't seen in the docs. I just need a place to display a preview of the image and little more functionality than maybe resizing it.

brian Fri 27 Mar 2009

Label is the correct widget to display an image:

Label { image = Image.makeFile(...) }

Do you need Image.resize? That is something on the todo list which didn't get done yet, but I can add it if you need it.

tactics Fri 27 Mar 2009

Thanks.

The resize is nothing mission-critical.

brian Sat 28 Mar 2009

@tactics

I pushed a change with a new Image.resize method.

Note that it doesn't support transparency correctly. The obvious thing (to reuse the same PaletteData from the source image) didn't work. So if anyone knows how to correctly do this in SWT, please let me know (a patch would be very welcome).

Also note, that the Graphics.copyImage which has always been in the API will let you draw a resized image too. See "examples/fwt/demo.fan" (line 735)

Login or Signup to reply.