Thursday, April 18, 2013

More versatile Canvas for showing images

To show a picture, the quick RealBasic way is to add a Canvas object to the window and assign a Picture to the Backdrop property of the Canvas. This will draw the image in the canvas space, stretched to the size of the canvas.

To have a bit more control over how the image is drawn, especially when using pre-drawn graphics as part of the user interface, this ImageCanvas control is made. It adds an Image property and allows selecting the mode of drawing, i.e. how the picture will be drawn.

The new ImageCanvas component is included in the example project. Use the menu to find and open an image file, or drag-and-drop an image file on the window. Use the controls to change the drawing mode and see how it changes the way the picture is drawn.
And of course; browse the code to see how it works and tweak as needed...


No comments:

Post a Comment