Script Library: 1238 scripts
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 
View scriptLicenseDownload documentation as: HTML or editable
Download scriptHistoryOther scripts by: vincentecuye

Documentation for: oneliner-image-viewer.r


REBOL

oneliner-image-viewer.r

Author: Vincent Ecuyer
Date: 29-Jan-2013

Contents:

1. Purpose
2. Usage
3. Commented Code

1. Purpose

A very small PNG/JPEG/BMP/GIF viewer.

2. Usage

'do the script, copy/paste the code in a /View console, or use it as a parameter the /View executable in a command line or a MS-Windows shortcut.

Clicking the "Load" box or a loaded picture opens a file requester, and if /View can load the selected picture the window will be resized to show it.

3. Commented Code

; Opens a new window, and stores the face! in 'l for later usage.
view l: layout [

    ; Uses the full window surface
    origin 0x0

    ; Labelled 100x100 box, which will serve as storage for pictures
    b: box "Load" [

        ; Actions executed on a click. "error? try" is the same as "attempt" in
        ; later versions: in case of error, exits the function but don't crashe
        error? try [

             ; requests a file and try to load it - 'i stores the image too for later access
             b/image: i: load first request-file

             ; if loading is a success, the text isn't needed anymore, so clears it
             b/text: ""

             ; resizes both the window ('l) and the box ('b) to the image ('i) size
             l/size: b/size: i/size

             ; updates the display
             show l
        ]
    ]
]
MakeDoc2 by REBOL- 29-Jan-2013