Rebol Programming/load-image

USAGE:

edit
LOAD-IMAGE image-file /update /clear 

DESCRIPTION:

edit

Load an image through an in-memory image cache.

LOAD-IMAGE is a function value.

ARGUMENTS:

edit
  • image-file -- Local file or remote URL (Type: file url)

REFINEMENTS:

edit
  • /update -- Force update from source site
  • /clear -- Purge the entire cache

SOURCE CODE

edit
load-image: func [
    "Load an image through an in-memory image cache." 
    image-file [file! url!] "Local file or remote URL" 
    /update "Force update from source site" 
    /clear "Purge the entire cache" 
    /local image image-cache
][
    image-cache: [] 
    if clear [system/words/clear image-cache recycle] 
    if any [update not image: select image-cache image-file] [
        if all [update image] [remove/part find image-cache image-file 2] 
        repend image-cache [
            image-file 
            image: either file? image-file [load image-file] [
                either update [load-thru/binary/update image-file] [load-thru/binary image-file]
            ]
        ]
    ] 
    image
]