Images

[ Back ]

For safety and compability reasons, NaaLaa uses only software routines for all drawing operations.

Sub routines

procedure load image image_id, filename$
procedure save image image_id, filename$
procedure create image image_id, w, h
procedure free image image_id
function image(image_id)
procedure set image colorkey image_id, value
procedure set image image_id
procedure draw image image_id, x, y
procedure draw image image_id, x, y, srx_x, srx_y, src_w, src_h
procedure draw image image_id, x, y, cel
procedure set image grid image_id, c, r
function cels(image_id)
function cols(image_id)
function rows(image_id)
function width(image_id)
function height(image_id)
procedure draw hraster image_id, y, x_start, x_end, u_start#, v_start#, u_end#, v_end#
procedure draw vraster image_id, x, y_start, y_end, u_start#, v_start#, u_end#, v_end#


procedure load image image_id, filename$

Load filename to image image_id. Supported file formats are JPG, PNG (24 and 32 bit), TGA, BMP (not RLE) and GIF.


procedure save image image_id, filename$

Save image image_id to filename (only bmp).


procedure create image image_id, w, h

Create image image_id and set its width and height to w and h.


procedure free image image_id

Free image image_id. All images are automaticly freed when program exits.


function image(image_id)

Returns true if image image_id exists.


procedure set image colorkey image_id, value

Make all occurences of pure magenta (RGB: 255, 0, 255) transparent when drawing image image_id if value is set to true. An image can only have one color key.


procedure set image image_id

Set destination image for all drawing operations to image_id. By default drawing is done to the primary image (the window's back buffer). You should therefor always pass primary as image_id when you're done drawing to another image.


procedure draw image image_id, x, y

Draw image image_id at x, y.


procedure draw image image_id, x, y, srx_x, srx_y, src_w, src_h

Draw part of image image_id, defined by the position src_x, src_y and the width and height src_w, src_h, to x, y.


procedure draw image image_id, x, y, cel

Draw cel of image image_id at x, y. See set image grid.


procedure set image grid image_id, c, r

Create a grid of c columns and r rows for image image_id. The above version of draw image can then be used to draw a certain cel of the image. Cels are indexed row by row starting with 0.


function cels(image_id)

Return number of cels in image image_id. See set image grid.


function cols(image_id)

Return number of columns in image image_id. See set image grid.


function rows(image_id)

Return number of rows in image image_id. See set image grid.


function width(image_id)

Return width (or cel width) of image image_id.


function height(image_id)

Return height (or cel height) of image image_id.


procedure draw hraster image_id, y, x_start, x_end, u_start#, v_start#, u_end#, v_end#

Draw a horizontal line from x_start, y to x_end, y. This line uses image image_id as a texture. The texture coordinates at x_start, y are u_start, v_start, and the texture coordinates at x_end, y are u_end, v_end. The texture coordinates are measured from the top left corner of image image_id, and they should be in the range 0..1 (where 1, 1 is the bottom right of the image).

This procedure does not handle transparency (alpha channel) of the source image, nor is it affected by the additive draw mode. Also, the color set with set color works as a "fog" on the texture. That is, if you use set color 255, 255, 255, 0, the texture will look as it does in the image image_id. But if you use set color 255, 255, 255, 255, the texture will be replaced by a solid white color.


procedure draw vraster image_id, x, y_start, y_end, u_start#, v_start#, u_end#, v_end#

Draw a vertical line from x, y_start to x, y_end. This line uses image image_id as a texture. The texture coordinates at x, y_start are u_start, v_start, and the texture coordinates at x, y_end are u_end, v_end. The texture coordinates are measured from the top left corner of image image_id, and they should be in the range 0..1 (where 1, 1 is the bottom right of the image).

For information about how set color affects this procedure, have a look at draw hraster.


[ Back ]