The Picture class allows you to display various kinds of picture (for example, JPEG, Windows bitmaps, or MacOS PICT images). The object can optionally include scroll bars for scrolling around the image (if the image is bigger than the object), or can allow stretching of the image to fit the object size. The image can be read from file, from an APL array of pixel color values, or from a stored vector of drawing commands.
See also the Draw method which allows you to draw icons, pictures and bitmaps on your windows and controls.
Properties to specify the image
You can specify the image which is displayed in one of four ways:
Reading back the bitmap property always returns an APL array of color values, so you can use this to convert an image from file (such as a JPEG picture) to a bitmap.
style: An integer comprising one of:
0 Picture is unscaled and centred 4 Picture is scaled to fit image 8 Picture is always scaled to fit frame, even when frame resized
to which can be added:
16 Vertical scroll bar (Not valid if style = 8) 64 Horizontal scroll bar (Not valid if style = 8) 128 Disable unnecessary scroll bars instead of removing them (MacOS only)
imagesize: The size (in current scale units) of the picture. This may be larger than or smaller than the size property of the object itself. If the style is 8, you cannot set imagesize, since it is always the same as the object size.
bitmapsize: The size (in current scale units) of the image within the picture.
∇DEMO_Picture;DEMO  ⍝ Sample function demonstrating use of the Picture object  DEMO←'⎕' ⎕NEW 'Window' ⋄ DEMO.scale←5 ⋄ DEMO.size←188 140  DEMO.title←'Picture'  DEMO.myPicture.New 'Picture' ⋄ DEMO.myPicture.align←¯1  ⍝  ⍝ Specify the picture either from a PICT or JPEG file, e.g.  ⍝  ⍝ Macintosh:  ⍝ DEMO.myPicture.file←'Macintosh HD:MyPicture'  ⍝  ⍝ Windows:  ⍝ DEMO.myPicture.file←'C:/MyFiles/MyPicture.jpg'  ⍝  ⍝ ...or put up a dialog asking the user to choose an image file:  ⍝  ⍝ DEMO.myPicture.file←''  ⍝  ⍝ ...or from an image held in a variable or the clipboard, e.g.  ⍝  ⍝ DEMO.myPicture.picture←('⎕' ⎕WI 'picture')  ⍝  ⍝  ⍝ ...or from an integer matrix of encoded RGB colour values, as here:  ⍝  DEMO.myPicture.bitmap←SAMPLE_BITMAP  ⍝  ⍝ Wait for the user to close the window  0 0⍴⎕WE DEMO ∇
align anchors aquaadjust autodraw bitmap bitmapsize border children class color data dragsource droptarget enabled events extent file imagesize maxsize methods minsize name opened picture pointer properties scale self size sourceformats style targetformats tie units visible where
Copyright © 1996-2010 MicroAPL Ltd