REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 23-Aug-2010 Edit History  

REBOL 3 Datatypes: Image!

Contents

Concept

The image! datatype is a series that holds RGBA images. This datatype is used with REBOL/View.

The external image formats supported are GIF, JPEG, PNG and BMP. The loaded image can be manipulated as a series.

Format

Images are normally loaded from a file. However, they can be expressed in source code as well by making an image. The block provided includes the image size and its RGBA data.

image: make image! [192x144 #{
    B34533B44634B44634B54735B7473
    84836B84836B84836BA4837BA4837
    BC4837BC4837BC4837BC4837BC483 ...
}

Creation

Empty images can be created using make or to-image:

empty-img: make image! 300x300 

empty-img: to-image 150x300

The size of the image is provided.

Images can also be made from snapshots of a face object. This is also done using make or to-image:

face-shot: make image! face 

face-shot: to-image face

Use load to load an image file. If the image's format is not supported, it will fail to load.

Loading an image:

img: load %bay.jpg

Related

Use image? to determine whether a value is the image! datatype:

probe image? img

Images are included in the series! typeset:

probe series? img

Use the /size refinement to return the pixel size of an image as a pair value:

probe img/size

Use the /rgb and /alpha refinements to get the RGB and A component separately as binary values.

probe img/rgb
probe img/alpha

The pixel values of an image are obtained using pick and changed using poke. The value returned by pick is an RGBA tuple value. The value replaced with poke also should be a tuple value of length 4.

Picking specific pixels:

probe pick img 1 

probe pick img 1500

Poking specific pixels:

poke img 1 255.255.255.0 
probe pick img 1 

poke img 1500 0.0.0.0 
probe pick img 1500


  TOC < Back Next > REBOL.com - WIP Wiki Feedback Admin