READIMAGE

Purpose:

Reads a BMP, GIF, JPEG, PNG, TIF and other image file formats.

Syntax:

READIMAGE("filename", "pixformat", aspect)

"filename"

-

A string, the filename or URL of the image file.

"pixformat"

-

Optional. A string, the resulting image pixel format. Defaults to "PBGRA32" (32-bit premultiplied BGRA) if omitted or empty. Supports the following pixel formats:

"Gray8"

:

8-bit grayscale (single channel, 256 shades)

"Alpha8"

:

8-bit alpha-only (opacity channel)

"Indexed8"

:

8-bit indexed color (palette lookup)

"BGR24"

:

24-bit BGR (8 bits per channel)

"RGB24"

:

24-bit RGB (8 bits per channel)

"BGR32"

:

32-bit BGR (8 bits per channel + padding)

"BGRA32"

:

32-bit BGRA (8 bits per channel)

"PBGRA32"

:

32-bit premultiplied BGRA (8 bits per channel)

"RGBA32"

:

32-bit RGBA (8 bits per channel)

"PRGBA32"

:

32-bit premultiplied RGBA (8 bits per channel)

"CMYK32"

:

32-bit CMYK (8 bits per channel)

"Y8"

:

8-bit Y (luma) component (YCbCr)

"Cb8"

:

8-bit Cb (blue chroma difference)

"Cr8"

:

8-bit Cr (red chroma difference)

aspect

-

Optional. In integer, the image aspect ratio. Defaults to -1, preserve image natural aspect ratio.

Returns:

An array.

Example:

W1: readimage(gethome + "data\mandrill.bmp")

W2: readimage(gethome + "data\logo.gif")

W3: readimage(gethome + "data\kasha.jpg");scalesoff

W4: readimage("https://science.nasa.gov/wp-content/uploads/2023/07/saturn-1.jpg")

 

W1 reads and displays the bitmap file "mandrill.bmp" in the aspect ratio of the image.

 

W2 reads and displays the GIF file "logo.gif" in the aspect ratio of the image.

 

 

W3 reads and displays the JPEG file "kasha.jpg", in the aspect ratio of the image and the scales are removed.

 

W4 reads an image of the planet Saturn directly from the internet.

Example:

W1: readimage(gethome + "data\mandrill.bmp", "Gray8")

 

W1 reads and displays the bitmap file "mandrill.bmp" using grayscale values raning from 0 to 255.

Remarks:

Unless pixformat is specified, the images are automatically converted to an internal RGBIMAGE using the "PBGRA32" (32-bit premultiplied BGRA) pixel format.

 

The type of image is determined by the filename extension. Supported extensions include BMP, GIF, JPG, PNG and TIF. See SAVEIMAGE for a current list of supported formats.

 

READIMAGE supports loading of images directly from a URL.

 

The default aspect value of -1 causes the window aspect ratio to match the aspect ratio of the contained image. See SETASPECT for more details on the aspect ratio.

See Also:

GETRGB

IMAGE24

IMCOMBINE

RGBIMAGE

SAVEIMAGE

SETASPECT

WRITEBMP