Topic: APLX Help : System Classes : List of Classes : Picture
[ Previous | Next | Contents | Index | APL Home ]



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:

  • By writing the name of an image file (for example, 'mypic.bmp' or 'myphoto.jpg') to the file property. This can be a full pathname and filename, or just a file name in the current directory. (For compatibility with other APL systems, you can alternatively write the name to the bitmap property). The image file must be of a type supported by the host system on which you are running APLX. If you write an empty vector to the file property, a dialog is displayed allowing the user to select an image file.

  • By writing an array of pixel color values to the bitmap property. The image is represented as an APL integer matrix, where each element contains an RGB color for the corresponding pixel. The color value is encoded as 256⊥Blue Green Red, where each color value is in the range 0 to 255. You can also write a boolean array where 0 represents black and 1 represents white.

  • By writing an integer vector containing drawing instructions (in the format appropriate to the host platform) to the picture property. Under MacOS, this is a PICT or JPEG object. Under Windows, it is a Windows Enhanced Metafile. In both cases, the data can for example be obtained from the clipboard (as the picture property of the System object). This option is not supported under Linux.

  • By creating an Image object as a child of the Picture object. In this case, the Picture will display the current image from the off-screen bitmap of the Image object. When the Image object is changed, the Picture will update automatically.

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.

Other properties

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.


[1]   ⍝ Sample function demonstrating use of the Picture object
[2]   DEMO←'⎕' ⎕NEW 'Window' ⋄ DEMO.scale←5 ⋄ DEMO.size←188 140
[3]   DEMO.title←'Picture'
[4]   DEMO.myPicture.New 'Picture' ⋄ DEMO.myPicture.align←¯1
[5]   ⍝
[6]   ⍝ Specify the picture either from a PICT or JPEG file, e.g.
[7]   ⍝
[8]   ⍝ Macintosh:
[9]   ⍝    DEMO.myPicture.file←'Macintosh HD:MyPicture'
[10]  ⍝
[11]  ⍝ Windows:
[12]  ⍝    DEMO.myPicture.file←'C:/MyFiles/MyPicture.jpg'
[13]  ⍝
[14]  ⍝ ...or put up a dialog asking the user to choose an image file:
[15]  ⍝
[16]  ⍝    DEMO.myPicture.file←''
[17]  ⍝
[18]  ⍝ ...or from an image held in a variable or the clipboard, e.g.
[19]  ⍝
[20]  ⍝    DEMO.myPicture.picture←('⎕' ⎕WI 'picture')
[21]  ⍝
[22]  ⍝
[23]  ⍝ ...or from an integer matrix of encoded RGB colour values, as here:
[24]  ⍝
[25]  DEMO.myPicture.bitmap←SAMPLE_BITMAP
[26]  ⍝
[27]  ⍝ Wait for the user to close the window
[28]  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


Click Clienttoscreen Close Create Delete Draw Hide New Open Paint Resize Screentoclient Send Set Show Trigger


onClick onClose onDblClick onDestroy onDragDrop onDragEnd onDragEnter onDragLeave onDragOver onDragStart onHide onMouseDown onMouseMove onMouseUp onOpen onSend onShow

Topic: APLX Help : System Classes : List of Classes : Picture
[ Previous | Next | Contents | Index | APL Home ]