跳轉到內容

Rebol 程式設計/load-image

來自華夏公益教科書,開放書籍,開放世界
LOAD-IMAGE image-file /update /clear 

透過記憶體中的影像快取載入影像。

LOAD-IMAGE 是一個函式值。

  • image-file -- 本地檔案或遠端 URL(型別:檔案 URL)
  • /update -- 強制從源站點更新
  • /clear -- 清除整個快取

原始碼

[編輯 | 編輯原始碼]
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
]
華夏公益教科書