Chapter 8. Image

Table of Contents

8.1. tsImageCreate
8.2. tsImageDestroy
8.3. tsImageLoad
8.4. tsImageAssignFrom
8.5. tsImageNew
8.6. tsImageGetInfo
8.7. tsImageGetIsEmpty
8.8. tsImageGetWidth
8.9. tsImageGetHeight
8.10. tsImageGetFormat
8.11. tsImageGetData
8.12. tsImageScanline
8.13. tsImageResize
8.14. tsImageBlend
8.15. tsImageBlur
8.16. tsImageFillColor
8.17. tsImageFillPattern

The images are quite simple. They only have a width, height, format and the data of the image. The image also supports some functions to handle the data. Like fill with an color, bluring or blending one image over another.

The image data only stores the data of the pixels one after another. It begins with the top row and ends with the last row. Inside an row the pixels are stored from left to the right. The figure below shows the format TS_FORMAT_RGBA8. The data from the pixels containing 4 components and each of it has an width of 8 bit. So the resulting size of an pixel is 32 Bit (4 Bytes). They are stored in following order. Red (1 Byte), Green (1 Byte), Blue (1 Byte) and Alpha (1 Byte).

Datastorage inside an image

Figure 8.1. Datastorage inside an image

Channel Description
TS_CHANNEL_RED Indicates the red channel.
TS_CHANNEL_GREEN Indicates the green channel.
TS_CHANNEL_BLUE Indicates the blue channel.
TS_CHANNEL_ALPHA Indicates the alpha channel.
TS_CHANNEL_LUMINANCE Indicates the luminance channel. (Luminance isn't supported by any format yet)
TS_CHANNELS_RGB Contains the flags for red, green and the blue channel.
TS_CHANNELS_RGBA Contains the flags for red, green, blue and the alpha channel.
TS_CHANNELS_LUMINANCE_ALPHA Contains the flags for luminance and the alpha channel. (Luminance isn't supported by any format yet)

Table 8.1. Channelsmasks

Mode Description
TS_MODE_REPLACE The destination value will fully replaced with the source value. This mode is the default value for all channels instead the alphachannel.
TS_MODE_MODULATE The destination and source value will be modulated. So if one of booth are zero the destination also will be zero. This value is the default value for the alpha channel.

Table 8.2. Image modes

Const OpenGL Const Red Green Blue Alpha Luminance
TS_FORMAT_EMPTY   empty empty empty empty empty
TS_FORMAT_RGBA8 GL_RGBA8 8 Bit 8 Bit 8 Bit 8 Bit  

Table 8.3. Formats