IMAGE LIBRARY
A Programming Language Manual



img_info
( lib: Images, file: ../src/gs/gslib_img.cpp )
int, int, int img_info( img )

IN
ptr img image
OUT
int width
int height
int bpp

Returns information of img image.

 C/C++ source code


img_setshader
( lib: Images, file: ../src/gs/gslib_img.cpp )
img_setshader( shader )

IN
int shader new shader to set

Set current drawing shader.

 C/C++ source code


img_getshader
( lib: Images, file: ../src/gs/gslib_img.cpp )
int img_getshader( )

OUT
int current shader

 C/C++ source code


img_create
( lib: Images, file: ../src/gs/gslib_img.cpp )
ptr img_create( width, height, bpp )

IN
int width
int height
int bpp
OUT
ptr image

Creates a new image.

 C/C++ source code


img_destroy
( lib: Images, file: ../src/gs/gslib_img.cpp )
img_destroy( image )

IN
ptr image

Destroys an image.

 C/C++ source code


img_flip
( lib: Images, file: ../src/gs/gslib_img.cpp )
img_flip( image )

IN
ptr image

Flip an image.

 C/C++ source code


img_save
( lib: Images, file: ../src/gs/gslib_img.cpp )
int img_save( image, filepath )

IN
ptr image
str filepath file path to save to
OUT
int 1=success, 0=fail

Saves an image to a file in TGA format.

 C/C++ source code


img_load
( lib: Images, file: ../src/gs/gslib_img.cpp )
ptr img_load( filepath )

IN
str filepath file path to save to
OUT
ptr image

Loads an image from a TGA file. Returns null if not found.

 C/C++ source code


img_fill
( lib: Images, file: ../src/gs/gslib_img.cpp )
img_fill( image, color )

IN
ptr image
tab color

Fill an image with a color.

 C/C++ source code


img_getpixel
( lib: Images, file: ../src/gs/gslib_img.cpp )
tab img_getpixel( image, x, y )

IN
ptr image
int x
int y
OUT
tab color

Read the pixel color from given coordinates.

 C/C++ source code


img_setpixel
( lib: Images, file: ../src/gs/gslib_img.cpp )
img_setpixel( image, x, y, color )

IN
ptr image
int x
int y
tab color

Write the pixel color at given coordinates.

 C/C++ source code


img_drawbar
( lib: Images, file: ../src/gs/gslib_img.cpp )
img_drawbar( img, x, y, w, h, color )

IN
ptr img
int x
int y
int w width
int h height
tab color

Draw a filled rectangle with given color. Using current shader.

 C/C++ source code


img_blit
( lib: Images, file: ../src/gs/gslib_img.cpp )
img_blit( imgsrc, x, y, w, h, imgdst, dx, dy, color )

IN
ptr imgsrc image source to copy from
int x source x
int y source y
int w source width
int h source height
ptr imgdst image destination to copy into
int dx destination x
int dy destination y
tab color multiply color (optional)

Copy a part of an image into another image. Using current shader.
Multiply source colors with given color.


 C/C++ source code


fnt_open
( lib: Images, file: ../src/gs/gslib_img.cpp )
int fnt_open( filepath, size, flags )

IN
str filepath font file path
int size font size
int flags font flags
OUT
int 1=success, 0=fail

Opens a font file for current use. See Font Flags
Ex: fnt_open("font.ttf", 10, FNT_FLAG_BOLD | FNT_FLAG_ANTI_ALIASING);


 C/C++ source code


fnt_close
( lib: Images, file: ../src/gs/gslib_img.cpp )
fnt_close( )

Closes the current opened font file.

 C/C++ source code


fnt_info
( lib: Images, file: ../src/gs/gslib_img.cpp )
int, int fnt_info( )

OUT
int height
int baseline

Get current font info.

 C/C++ source code


fnt_setspacing
( lib: Images, file: ../src/gs/gslib_img.cpp )
fnt_setspacing( spaceX, spaceY )

IN
int spaceX
int spaceY

Set current font spacing.

 C/C++ source code


fnt_getspacing
( lib: Images, file: ../src/gs/gslib_img.cpp )
int, int fnt_getspacing( )

OUT
int spaceX
int spaceY

Get current font spacing.

 C/C++ source code


fnt_usekerning
( lib: Images, file: ../src/gs/gslib_img.cpp )
fnt_usekerning( useKerning )

IN
int useKerning

If current should use kerning.

 C/C++ source code


fnt_gettextmetrics
( lib: Images, file: ../src/gs/gslib_img.cpp )
int, int fnt_gettextmetrics( w, h, text, wrap )

IN
int w width
int h height
str text
int wrap (optional)
OUT
int width
int height

Get width and height needed to fit a given text.

 C/C++ source code


fnt_rendertext
( lib: Images, file: ../src/gs/gslib_img.cpp )
fnt_rendertext( img, x, y, w, h, text, color, wrap, align )

IN
ptr img destination image
int x
int y
int w width
int h height
str text
tab color
int wrap 0=no (default), 1=yes (optional)
int align -1=left (default), 0=center, 1=right (optional)

Draw given text with color into the img image, inside the given area.

 C/C++ source code


COLOR
( lib: Images, file: ../src/gs/gslib_img.cpp )
tab COLOR( hex )

IN
str hex hexadecimal color
OUT
tab color

Convert form hexadecimal to a color table.
A table color can be indexed with special indexes .r .g .b .a
Ex: color.a is the same as color[3]


 C/C++ source code


color_hex
( lib: Images, file: ../src/gs/gslib_img.cpp )
str color_hex( color )

IN
tab color
OUT
str hexadecimal color

Convert form color table to hexadecimal.

 C/C++ source code


IMG_SHADER_COPY
( lib: Images, file: ../src/gs/gslib_img.cpp )
IMG_SHADER_COPY

Shader for direct RGBA copy.


IMG_SHADER_COPY_RGB
( lib: Images, file: ../src/gs/gslib_img.cpp )
IMG_SHADER_COPY_RGB

Shader for direct RGB copy only.


IMG_SHADER_COPY_A
( lib: Images, file: ../src/gs/gslib_img.cpp )
IMG_SHADER_COPY_A

Shader for direct A (alpha) copy only.


IMG_SHADER_ALPHA_BLEND
( lib: Images, file: ../src/gs/gslib_img.cpp )
IMG_SHADER_ALPHA_BLEND

Shader for blending source with destination based on destination alpha (RGB): DST = SRC * SRC.A + DST * (1 - SRC.A)


IMG_SHADER_ALPHA_ADD
( lib: Images, file: ../src/gs/gslib_img.cpp )
IMG_SHADER_ALPHA_ADD

Additive shader (RGB): DST = DST + SRC.


IMG_SHADER_ALPHA_SUB
( lib: Images, file: ../src/gs/gslib_img.cpp )
IMG_SHADER_ALPHA_SUB

Subtractive shader (RGB): DST = DST - SRC.


IMG_SHADER_ALPHA_MUL
( lib: Images, file: ../src/gs/gslib_img.cpp )
IMG_SHADER_ALPHA_MUL

Multiplicative shader (RGB): DST = DST * SRC;


IMG_SHADER_ALPHA_MUL2X
( lib: Images, file: ../src/gs/gslib_img.cpp )
IMG_SHADER_ALPHA_MUL2X

Multiplicative shader 2X (RGB): DST = DST * SRC * 2;


FNT_FLAG_BOLD
( lib: Images, file: ../src/gs/gslib_img.cpp )
FNT_FLAG_BOLD

Bold flag for font open.


FNT_FLAG_ITALIC
( lib: Images, file: ../src/gs/gslib_img.cpp )
FNT_FLAG_ITALIC

Italic flag for font open.


FNT_FLAG_ANTI_ALIASING
( lib: Images, file: ../src/gs/gslib_img.cpp )
FNT_FLAG_ANTI_ALIASING

Antialiasing flags for font open.