openTRI 0.1
Image

Data Structures

struct  triImageFileHeader
 Image File Header. More...
struct  triImageChunkHeader
struct  triImageChunk
struct  triMipLevel
struct  triImage
 Image struct. More...
struct  triImageSlice
 Image slice struct. More...
struct  triImageLarge
 Large Image struct. More...
struct  triImageAnimation
 ImageAnimation struct. More...

Macros

#define IMG_FORMAT_5650   GU_PSM_5650
 Pixelformat R5:G6:B5:A0.
#define IMG_FORMAT_5551   GU_PSM_5551
 Pixelformat R5:G5:B5:A1.
#define IMG_FORMAT_4444   GU_PSM_4444
 Pixelformat R4:G4:B4:A4.
#define IMG_FORMAT_8888   GU_PSM_8888
 Pixelformat R8:G8:B8:A8.
#define IMG_FORMAT_T4   GU_PSM_T4
 Pixelformat 4bit indexed.
#define IMG_FORMAT_T8   GU_PSM_T8
 Pixelformat 8bit indexed.
#define IMG_FORMAT_T16   GU_PSM_T16
 Pixelformat 16bit indexed.
#define IMG_FORMAT_T32   GU_PSM_T32
 Pixelformat 32bit indexed.
#define IMG_FORMAT_DXT1   GU_PSM_DXT1
 Pixelformat DXT1 compressed.
#define IMG_FORMAT_DXT3   GU_PSM_DXT3
 Pixelformat DXT3 compressed.
#define IMG_FORMAT_DXT5   GU_PSM_DXT5
 Pixelformat DXT5 compressed.
#define TRI_RAM   0x0000
 Load image in system ram.
#define TRI_VRAM   0x0001
 Load image in VRAM.
#define TRI_SWIZZLE   0x0002
 Swizzle image.
#define TRI_FRAME(x)
 Load frame number x [0-2097151] from file (only for .tri)
#define TRI_LEVEL(x)
 Load level number x [0-7] from file (only for .tri)
#define TRI_IMG_FLAGS_SWIZZLE   0x0001
 Swizzled image data.
#define TRI_IMG_FLAGS_RLE   0x0002
 RLE compressed image data.
#define TRI_IMG_FLAGS_GZIP   0x0004
 GZIP compressed image data.
#define TRI_IMG_FLAGS_WAVELET   0x0008
 Wavelet compressed image data (stores mipmaps as integral part of the actual image)
#define PACKED   __attribute__((packed))

Functions

struct triImageFileHeader __attribute__ ((packed)) triImageFileHeader
 Image File Header.
triVoid triImagePaletteGet (triImage *img, triU32 col, triU32 *r, triU32 *g, triU32 *b, triU32 *a)
 Get a palette entry from image.
triVoid triImagePaletteSet (triImage *img, triU32 col, triU32 r, triU32 g, triU32 b, triU32 a)
 Set a palette entry in image.
triVoid triImageSwizzleToVRAM (triImage *img)
 Swizzle and upload an image to VRAM for faster drawing.
triVoid triImageSwizzle (triImage *img)
 Swizzle an image for faster drawing.
triVoid triImageUnswizzle (triImage *img)
 Unswizzle an image.
triVoid triImageToVRAM (triImage *img)
 Upload an image to VRAM for faster drawing.
triVoid triImageToRAM (triImage *img)
 Download an image to RAM.
triVoid triImageFree (triImage *img)
 Free an image.
triVoid triImageAnimationFree (triImageAnimation *img)
 Free an image animation.
triImagetriImageGet (triS32 x, triS32 y, triS32 width, triS32 height)
 Capture part of framebuffer to image.
triImagetriImageSet (triS32 width, triS32 height, triS32 stride, triS32 bits, triS32 psm, triVoid *data)
 Create an image from a memory buffer.
triImagetriImageLoadRaw (triChar *name)
 Load image from a .raw file.
triImagetriImageLoadRawStream (stream *s)
 Load RAW image from a stream.
triImagetriImageLoadTga (triChar *name)
 Load image from a .tga file.
triImagetriImageLoadTgaStream (stream *s)
 Load TGA image from a stream.
triImagetriImageLoadTri (triChar *name, triU32 frame)
 Load image from a .tri file.
triImagetriImageLoadTriStream (stream *s, triU32 frame)
 Load TRI image from a stream.
triImagetriImageLoad (triChar *name, triU32 flags)
 Generic file loader.
triImagetriImageLoadStream (stream *s, triU32 flags)
 Generic stream file loader.
triVoid triImageSaveTga (triChar *name, triImage *img, triS32 saveAlpha, triS32 rle)
 Save image to a .tga file.
triVoid triImageSaveTri (triChar *name, triImage *img, triU32 flags)
 Save image to a .tri file.
triImageAnimationtriImageAnimationCreate ()
 Create a new blank triImageAnimation structure.
triImageAnimationtriImageAnimationFromSheet (triImage *img, triS32 fwidth, triS32 fheight, triS32 hframes, triS32 vframes, triU32 delay)
 Create an animation from an imagesheet in order left-right, top-down.
triImageAnimationtriImageAnimationFromSheet2 (triImage *img, triS32 xoffs, triS32 yoffs, triS32 fwidth, triS32 fheight, triS32 hframes, triS32 vframes, triU32 delay)
 Create an animation from an imagesheet in order left-right, top-down.
triImageAnimationtriImageAnimationFromSheetTga (triChar *name, triS32 fwidth, triS32 fheight, triS32 hframes, triS32 vframes, triU32 delay)
 Create an animation from an imagesheet in a Tga file, in order left-right, top-down.
triImageAnimationtriImageAnimationFromSheetFile (triChar *name, triS32 fwidth, triS32 fheight, triS32 hframes, triS32 vframes, triU32 delay)
 Create an animation from an imagesheet in a file, in order left-right, top-down.
triImageAnimationtriImageAnimationFromSheetFile2 (triChar *name, triS32 xoffs, triS32 yoffs, triS32 fwidth, triS32 fheight, triS32 hframes, triS32 vframes, triU32 delay)
 Create an animation from an imagesheet in a file, in order left-right, top-down.
triVoid triImageAnimationAppend (triImageAnimation *ani, triImage *img, triS32 sx, triS32 sy, triS32 sw, triS32 sh, triS32 x_offs, triS32 y_offs, triU32 delay)
 Append a loaded triImage as last frame to an animation.
triVoid triImageAnimationAppend2 (triImageAnimation *ani, triImage *img, triU32 delay)
 Append a loaded triImage as last frame to an animation.
triVoid triImageAnimationAppend3 (triImageAnimation *ani, triImage *img, triS32 xOffs, triS32 yOffs, triU32 delay)
 Append a loaded triImage as last frame to an animation.
triImageAnimationtriImageAnimationLoadGif (triChar *name)
triImageAnimationtriImageAnimationLoadGifStream (stream *s)
triImageAnimationtriImageAnimationLoadTri (triChar *name)
 Load image animation from a .tri file.
triImageAnimationtriImageAnimationLoadTriStream (stream *s)
 Load image animation from a stream.
void triImageAnimationSaveTri (triChar *name, triImageAnimation *ani, triS32 flags)
 Save image animation to a .tri file.
triVoid triImageAnimationStart (triImageAnimation *ani)
 Start animation.
triVoid triImageAnimationPause (triImageAnimation *ani)
 Pause animation.
triVoid triImageAnimationReset (triImageAnimation *ani)
 Reset animation (Stop+Rewind).
triS32 triImageAnimationUpdate (triImageAnimation *ani)
 Update animation.
triVoid triImageAnimationSetSpeed (triImageAnimation *ani, triFloat factor)
 Set animation speed.
triBool triImageAnimationIsDone (triImageAnimation *ani)
 Return if animation is finished.
triImagetriImageAnimationGetFrame (triImageAnimation *ani, triS32 nFrame)
 Return one frame from animation.

Detailed Description

Macro Definition Documentation

◆ TRI_FRAME

#define TRI_FRAME ( x)
Value:
(((x) & ~0x7FF) << 11)

Load frame number x [0-2097151] from file (only for .tri)

◆ TRI_LEVEL

#define TRI_LEVEL ( x)
Value:
(((x) & 0x7) << 8)

Load level number x [0-7] from file (only for .tri)

Function Documentation

◆ __attribute__()

struct triImageFileHeader __attribute__ ( (packed) )

Image File Header.

ImageAnimation struct.

Large Image struct.

Image slice struct.

Image struct.

Max 1024xN.

Contains an image region of max 512x512 pixels.

Used to load and draw large images.

◆ triImagePaletteGet()

triVoid triImagePaletteGet ( triImage * img,
triU32 col,
triU32 * r,
triU32 * g,
triU32 * b,
triU32 * a )

Get a palette entry from image.

Parameters
*img- Pointer to image containing the palette
col- Palette entry index
*r- Pointer to U32 to contain the red component (0-255)
*g- Pointer to U32 to contain the green component (0-255)
*b- Pointer to U32 to contain the blue component (0-255)

◆ triImagePaletteSet()

triVoid triImagePaletteSet ( triImage * img,
triU32 col,
triU32 r,
triU32 g,
triU32 b,
triU32 a )

Set a palette entry in image.

Parameters
*img- Pointer to image containing the palette
col- Palette entry index
r- Red component (0-255)
g- Green component (0-255)
b- Blue component (0-255)

◆ triImageSwizzleToVRAM()

triVoid triImageSwizzleToVRAM ( triImage * img)

Swizzle and upload an image to VRAM for faster drawing.

Parameters
*img- Pointer to image

◆ triImageSwizzle()

triVoid triImageSwizzle ( triImage * img)

Swizzle an image for faster drawing.

Parameters
*img- Pointer to image

◆ triImageUnswizzle()

triVoid triImageUnswizzle ( triImage * img)

Unswizzle an image.

Parameters
*img- Pointer to image

◆ triImageToVRAM()

triVoid triImageToVRAM ( triImage * img)

Upload an image to VRAM for faster drawing.

Parameters
*img- Pointer to image

◆ triImageToRAM()

triVoid triImageToRAM ( triImage * img)

Download an image to RAM.

Parameters
*img- Pointer to image

◆ triImageFree()

triVoid triImageFree ( triImage * img)

Free an image.

Parameters
*img- Pointer to image

◆ triImageAnimationFree()

triVoid triImageAnimationFree ( triImageAnimation * img)

Free an image animation.

Parameters
*img- Pointer to image animation

◆ triImageGet()

triImage * triImageGet ( triS32 x,
triS32 y,
triS32 width,
triS32 height )

Capture part of framebuffer to image.

Parameters
x- X-coordinate of rect to capture
y- Y-coordinate of rect to capture
width- Width of rect to capture
height- Height of rect to capture
Returns
Pointer to image containing the framebuffer part

◆ triImageSet()

triImage * triImageSet ( triS32 width,
triS32 height,
triS32 stride,
triS32 bits,
triS32 psm,
triVoid * data )

Create an image from a memory buffer.

Parameters
width- Width of image
height- Height of image
stride- Allocated width of image (buffer width)
bits- Bits of image
psm- Format of image - one of IMG_FORMAT_*
data- Pointer to memory containing the image data
Returns
Pointer to image structure containing the data

◆ triImageLoadRaw()

triImage * triImageLoadRaw ( triChar * name)

Load image from a .raw file.

Parameters
name- Filename of file to load
Returns
Pointer to image structure containing the image

◆ triImageLoadRawStream()

triImage * triImageLoadRawStream ( stream * s)

Load RAW image from a stream.

Parameters
s- Opened stream to read from
Returns
Pointer to image structure containing the image

◆ triImageLoadTga()

triImage * triImageLoadTga ( triChar * name)

Load image from a .tga file.

Parameters
name- Filename of file to load
Returns
Pointer to image structure containing the image

◆ triImageLoadTgaStream()

triImage * triImageLoadTgaStream ( stream * s)

Load TGA image from a stream.

Parameters
s- Opened stream to read from
Returns
Pointer to image structure containing the image

◆ triImageLoadTri()

triImage * triImageLoadTri ( triChar * name,
triU32 frame )

Load image from a .tri file.

Parameters
name- Filename of file to load
frame- Frame number of file to load
level- Sublevel to load (0-7)
Returns
Pointer to image structure containing the image

◆ triImageLoadTriStream()

triImage * triImageLoadTriStream ( stream * s,
triU32 frame )

Load TRI image from a stream.

Parameters
s- Opened stream to read from
frame- Frame number of file to load
level- Sublevel to load (0-7)
Returns
Pointer to image structure containing the image

◆ triImageLoad()

triImage * triImageLoad ( triChar * name,
triU32 flags )

Generic file loader.

Loads .tga, .tri and .png.

Parameters
name- Filename of file to load
flags- flags to apply to the image (one of TRI_RAM/TRI_VRAM/TRI_SWIZZLE)
Returns
Pointer to image structure containing the image

◆ triImageLoadStream()

triImage * triImageLoadStream ( stream * s,
triU32 flags )

Generic stream file loader.

Loads .tga, .tri and .png.

Parameters
s- Stream to load from
flags- flags to apply to the image (one of TRI_RAM/TRI_VRAM/TRI_SWIZZLE)
Returns
Pointer to image structure containing the image

◆ triImageSaveTga()

triVoid triImageSaveTga ( triChar * name,
triImage * img,
triS32 saveAlpha,
triS32 rle )

Save image to a .tga file.

Parameters
name- Filename of file to save
img- Pointer to image to save
saveAlpha- Whether to save the alpha channel with the image
rle- Whether to RLE compress image

◆ triImageSaveTri()

triVoid triImageSaveTri ( triChar * name,
triImage * img,
triU32 flags )

Save image to a .tri file.

Parameters
name- Filename of file to save
img- Pointer to image to save
flags- any combination of TRI_IMG_FLAGS_*

◆ triImageAnimationCreate()

triImageAnimation * triImageAnimationCreate ( )

Create a new blank triImageAnimation structure.

Returns
Pointer to new triImageAnimation struct

◆ triImageAnimationFromSheet()

triImageAnimation * triImageAnimationFromSheet ( triImage * img,
triS32 fwidth,
triS32 fheight,
triS32 hframes,
triS32 vframes,
triU32 delay )

Create an animation from an imagesheet in order left-right, top-down.

Parameters
img- Pointer to triImage containing spritesheet
fwidth- Width of one frame in sheet
fheight- Height of one frame in sheet
hframes- Number of horizontal frames
vframes- Number of vertical frames
delay- Delay to apply per frame, given in ms
Returns
Pointer to new triImageAnimation struct

◆ triImageAnimationFromSheet2()

triImageAnimation * triImageAnimationFromSheet2 ( triImage * img,
triS32 xoffs,
triS32 yoffs,
triS32 fwidth,
triS32 fheight,
triS32 hframes,
triS32 vframes,
triU32 delay )

Create an animation from an imagesheet in order left-right, top-down.

Parameters
img- Pointer to triImage containing spritesheet
xoffs- X offset where the frames should start
yoffs- Y offset where the frames should start
fwidth- Width of one frame in sheet
fheight- Height of one frame in sheet
hframes- Number of horizontal frames
vframes- Number of vertical frames
delay- Delay to apply per frame, given in ms
Returns
Pointer to new triImageAnimation struct

◆ triImageAnimationFromSheetTga()

triImageAnimation * triImageAnimationFromSheetTga ( triChar * name,
triS32 fwidth,
triS32 fheight,
triS32 hframes,
triS32 vframes,
triU32 delay )

Create an animation from an imagesheet in a Tga file, in order left-right, top-down.

Parameters
name- Filename of Tga image to load from.
fwidth- Width of one frame in sheet
fheight- Height of one frame in sheet
hframes- Number of horizontal frames
vframes- Number of vertical frames
delay- Delay to apply per frame, given in ms
Returns
Pointer to new triImageAnimation struct

◆ triImageAnimationFromSheetFile()

triImageAnimation * triImageAnimationFromSheetFile ( triChar * name,
triS32 fwidth,
triS32 fheight,
triS32 hframes,
triS32 vframes,
triU32 delay )

Create an animation from an imagesheet in a file, in order left-right, top-down.

Parameters
name- Filename of image to load from.
fwidth- Width of one frame in sheet
fheight- Height of one frame in sheet
hframes- Number of horizontal frames
vframes- Number of vertical frames
delay- Delay to apply per frame, given in ms
Returns
Pointer to new triImageAnimation struct

◆ triImageAnimationFromSheetFile2()

triImageAnimation * triImageAnimationFromSheetFile2 ( triChar * name,
triS32 xoffs,
triS32 yoffs,
triS32 fwidth,
triS32 fheight,
triS32 hframes,
triS32 vframes,
triU32 delay )

Create an animation from an imagesheet in a file, in order left-right, top-down.

Parameters
name- Filename of image to load from.
xoffs- X offset where the frames should start
yoffs- Y offset where the frames should start
fwidth- Width of one frame in sheet
fheight- Height of one frame in sheet
hframes- Number of horizontal frames
vframes- Number of vertical frames
delay- Delay to apply per frame, given in ms
Returns
Pointer to new triImageAnimation struct

◆ triImageAnimationAppend()

triVoid triImageAnimationAppend ( triImageAnimation * ani,
triImage * img,
triS32 sx,
triS32 sy,
triS32 sw,
triS32 sh,
triS32 x_offs,
triS32 y_offs,
triU32 delay )

Append a loaded triImage as last frame to an animation.

Parameters
ani- Pointer to triAnimationImage to append the image to
img- Pointer to triImage to append
sx- X-coordinate of source image rect
sy- Y-coordinate of source image rect
sw- Width of source image rect
sh- Height of source image rect
x_offs- Offset in X-coordinate to draw the image
y_offs- Offset in Y-coordinate to draw the image
delay- Delay to apply per frame, given in ms

◆ triImageAnimationAppend2()

triVoid triImageAnimationAppend2 ( triImageAnimation * ani,
triImage * img,
triU32 delay )

Append a loaded triImage as last frame to an animation.

Parameters
ani- Pointer to triAnimationImage to append the image to
img- Pointer to triImage to append
delay- Delay to apply per frame, given in ms

◆ triImageAnimationAppend3()

triVoid triImageAnimationAppend3 ( triImageAnimation * ani,
triImage * img,
triS32 xOffs,
triS32 yOffs,
triU32 delay )

Append a loaded triImage as last frame to an animation.

Parameters
ani- Pointer to triAnimationImage to append the image to
img- Pointer to triImage to append
x_offs- Offset in X-coordinate to draw the image
y_offs- Offset in Y-coordinate to draw the image
delay- Delay to apply per frame, given in ms

◆ triImageAnimationLoadTri()

triImageAnimation * triImageAnimationLoadTri ( triChar * name)

Load image animation from a .tri file.

Parameters
name- Filename of file to load
Returns
Pointer to triImageAnimation structure containing the image animation

◆ triImageAnimationLoadTriStream()

triImageAnimation * triImageAnimationLoadTriStream ( stream * s)

Load image animation from a stream.

Parameters
s- Opened stream to read from
Returns
Pointer to triImageAnimation structure containing the image animation

◆ triImageAnimationSaveTri()

void triImageAnimationSaveTri ( triChar * name,
triImageAnimation * ani,
triS32 flags )

Save image animation to a .tri file.

Parameters
name- Filename of file to save
ani- Pointer to triImageAnimation structure to save
flags- any combination of TRI_IMG_FLAGS_*

◆ triImageAnimationStart()

triVoid triImageAnimationStart ( triImageAnimation * ani)

Start animation.

Parameters
ani- Pointer to triAnimationImage

◆ triImageAnimationPause()

triVoid triImageAnimationPause ( triImageAnimation * ani)

Pause animation.

Parameters
ani- Pointer to triAnimationImage

◆ triImageAnimationReset()

triVoid triImageAnimationReset ( triImageAnimation * ani)

Reset animation (Stop+Rewind).

Parameters
ani- Pointer to triAnimationImage

◆ triImageAnimationUpdate()

triS32 triImageAnimationUpdate ( triImageAnimation * ani)

Update animation.

Parameters
ani- Pointer to triAnimationImage
Returns
0 if animation wasn't updated

◆ triImageAnimationSetSpeed()

triVoid triImageAnimationSetSpeed ( triImageAnimation * ani,
triFloat factor )

Set animation speed.

Parameters
ani- Pointer to triAnimationImage
factor- Float specifying the speed - 1.0 = normal speed, 2.0 = double speed

◆ triImageAnimationIsDone()

triBool triImageAnimationIsDone ( triImageAnimation * ani)

Return if animation is finished.

Parameters
ani- Pointer to triAnimationImage
Returns
boolean indicating the state

◆ triImageAnimationGetFrame()

triImage * triImageAnimationGetFrame ( triImageAnimation * ani,
triS32 nFrame )

Return one frame from animation.

Parameters
ani- Pointer to triAnimationImage
nFrame- Number of Frame to return (starting at 0)
Returns
Pointer to animation image