MTek-GDL 0.100.4-muffintrap
Loading...
Searching...
No Matches
Public Member Functions | Data Fields
gdl::ImageWii Class Reference

Image handling class. More...

#include <mgdl-wii-image.h>

Collaboration diagram for gdl::ImageWii:
Collaboration graph
[legend]

Public Member Functions

 ImageWii ()
 Constructor.
 
virtual ~ImageWii ()
 Deconstructor.
 
bool Create (short xRes, short yRes, u_int filterMode, u_int format=RGBA8)
 Creates an image.
 
bool CreateMipmapped (short xSize, short ySize, u_int minFilt, u_int magFilt, short maxMipmaps, u_int format=gdl::RGBA8)
 Creates a mipmapped image.
 
bool LoadImage (const char *fileName, u_int filterMode, u_int format=RGBA8)
 Loads an image.
 
bool LoadImageMipmapped (const char *fileName, u_int minFilt, u_int magFilt, short maxMipmaps, u_int format=gdl::RGBA8)
 Loads an image with mipmap generation.
 
bool LoadImageMem (void *imagePtr, u_int filterMode, u_int format)
 Loads an image from a memory block.
 
bool LoadImageBuffer (const void *buffer, size_t size, u_int filterMode, u_int format)
 Loads an image from memory.
 
short Xsize ()
 Returns the X size of the image in pixels.
 
short Ysize ()
 Returns the Y size of the image in pixels.
 
void Put (short x, short y, Color4f *col, short cx=0, short cy=0, float scale=1.f, float angle=0.f)
 Draws the image onto the screen with more options.
 
void PutS (short x1, short y1, short x2, short y2, Color4f *col)
 Draws an image as a stretchable rectangle.
 

Data Fields

gdl::Texture Texture
 gdl::Texture object containing the actual texture data of the image.
 

Detailed Description

Image handling class.

This class is used for loading and drawing images with ease similar to SFML's sf::Image class. It also contains a gdl::Texture object for storing the actual image data and can be used for custom graphics routines.

Note
It is not advisable to use this class for handling several individual sprite images. Instead, Use the gdl::SpriteSet class.

Member Function Documentation

◆ Create()

bool gdl::ImageWii::Create ( short  xRes,
short  yRes,
u_int  filterMode,
u_int  format = RGBA8 
)

Creates an image.

This function allocates texture and vertex array buffers for handling and drawing an image. The class contains a gdl::Texture object for storing the actual image data and you can use it to alter the texture data of the image.

Note
If the image has already been created before, it will reallocate the texture and vertex buffers of the image. However, it is not advisable to do this too frequently.
This function does not need to be called when loading an image file with gdl::Image::LoadImage() as that function already creates the image for you.
Parameters
[in]xResX size of texture in pixels.
[in]yResY size of texture in pixels.
[in]filterModeImage filter mode (see gdl::TextureFilterModes).
[in]formatTexture format (see gdl::TextureFormatModes).
Returns
Non-zero if the image had been allocated successfully otherwise there isn't enough memory to allocate it.

◆ CreateMipmapped()

bool gdl::ImageWii::CreateMipmapped ( short  xSize,
short  ySize,
u_int  minFilt,
u_int  magFilt,
short  maxMipmaps,
u_int  format = gdl::RGBA8 
)

Creates a mipmapped image.

Similar to gdl::Image::Create() but it creates a mipmapped image which improves rendering quality (and in some cases, performance) when the image gets downscaled.

Note
See gdl::Texture::CreateMipmapped() for details.
If the image has already been created before, it will reallocate the texture and vertex buffers of the image. However, it is not advisable to do this too frequently.
This function does not need to be called when loading an image file with gdl::Image::LoadImageMipmapped() as that function already creates an image for you.
Parameters
[in]xSizeX size of texture in pixels.
[in]ySizeY size of texture in pixels.
[in]minFiltFar filter mode (see gdl::TextureFilterModes).
[in]magFiltNear filter mode (see gdl::TextureFilterModes).
[in]maxMipmapsMaximum number of mipmap levels to generate.
[in]formatTexture format (see gdl::TextureFormatModes).
Returns
Non-zero if the image had been allocated successfully otherwise there isn't enough memory to create it.

◆ LoadImage()

bool gdl::ImageWii::LoadImage ( const char *  fileName,
u_int  filterMode,
u_int  format = RGBA8 
)

Loads an image.

Loads an image file, internally creates texture and image buffers and then converts the image data into a texture. This version of the library only supports PNG image files that are in grayscale, 8-bit palletized, RGB, and RGBA color formats as well as TPL texture files containing a single texture. There will be no support for interlaced PNG images.

It is advisable that you use an appropriate texture format if you wish to save as much MEM1 memory as possible such as using gdl::RGB5A3 for images that have simple transparency (like pixel art sprites) and gdl::RGB565 for images that have no alpha channel. Using such texture formats may result in slight color quality loss however so use it in situations where color definition is not so important.

Note
When a TPL texture file is being loaded, the filterMode and format parameters are ignored.
This function will allocate temporary buffers used for converting the image data into an appropriate texture format. These buffers are allocated in MEM2 using malloc2() to reduce memory fragmentation in MEM1 when loading a lot of individual images with varying resolutions.
Parameters
[in]fileNameFile name of image file to load.
[in]filterModeImage filter mode (see gdl::TextureFilterModes).
[in]formatTexture format (see gdl::TextureFormatModes).
Returns
Non-zero if the image was successfully loaded otherwise an error occurred.

◆ LoadImageBuffer()

bool gdl::ImageWii::LoadImageBuffer ( const void buffer,
size_t  size,
u_int  filterMode,
u_int  format 
)

Loads an image from memory.

Similar to gdl::LoadImage() but this function loads an image file from a memory address. This is most useful when making standalone DOL executables where image data is embedded into the program.

Note
Unlike gdl::LoadImage() which supports TPL texture files, this function only supports PNG images.
Parameters
[in]bufferPointer to a memory block containing an image file.
[in]sizeSize of the buffer in bytes
[in]filterModeFiltering mode (see gdl::TextureFilterModes).
[in]formatTexture format (see gdl::TextureFormatModes).
Returns
Non-zero if the image was successfully loaded, otherwise an error occured (detailed error is printed in console mode).

◆ LoadImageMem()

bool gdl::ImageWii::LoadImageMem ( void imagePtr,
u_int  filterMode,
u_int  format 
)

Loads an image from a memory block.

Similar to gdl::LoadImage() but this function loads an image file from a memory address. This is most useful when making standalone DOL executables where image data is embedded into the program.

Note
Unlike gdl::LoadImage() which supports TPL texture files, this function only supports PNG images.
Parameters
[in]imagePtrPointer to a memory block containing an image file.
[in]filterModeFiltering mode (see gdl::TextureFilterModes).
[in]formatTexture format (see gdl::TextureFormatModes).
Returns
Non-zero if the image was successfully loaded, otherwise an error occured (detailed error is printed in console mode).

◆ LoadImageMipmapped()

bool gdl::ImageWii::LoadImageMipmapped ( const char *  fileName,
u_int  minFilt,
u_int  magFilt,
short  maxMipmaps,
u_int  format = gdl::RGBA8 
)

Loads an image with mipmap generation.

Similar to gdl::Image::LoadImage() but it also generates mipmaps of the image.

With mipmapped images, aliasing issues will be eliminated when you scale down an image from its original
resolution. Since mipmapped images take up a bit more memory than a non-mipmapped image, use it wisely for
graphics that scale down tremendously or textures of environments.
Note
Unlike gdl::Image::LoadImage(), this function will take slightly longer to load an image and takes up more MEM2 memory temporarily due to on-the-fly mipmap generation.
See gdl::Texture::CreateMipmapped() for details about mipmaps.
Parameters
[in]fileNameFile name of image to load.
[in]minFiltFilter mode when image is drawn smaller than original size (see gdl::TextureFilterModes).
[in]magFiltFilter mode when image is drawn bigger than original size (see gdl::TextureFilterModes).
[in]maxMipmapsThe maximum number of mipmaps to generate (9 is the maximum value).
[in]formatTexture format (see gdl::TextureFormatModes).
Returns
Non-zero if the image and mipmaps were successfully loaded and generated, otherwise an error occured (detailed error is printed in console mode).

◆ Put()

void gdl::ImageWii::Put ( short  x,
short  y,
Color4f col,
short  cx = 0,
short  cy = 0,
float  scale = 1.f,
float  angle = 0.f 
)

Draws the image onto the screen with more options.

Draws the image with color translation and optional rotation and scaling. This function must only be called between a gdl::PrepDisplay() and gdl::Display() pair and if no image is loaded in this class, nothing is drawn.

Parameters
[in]xX coordinate of image.
[in]yY coordinate of image.
[in]colColor of image (use gdl::Color::White or full white or RGBA() for normal colors).
[in]cxX offset of image pivot (you can also use one of the gdl::AlignmentModes).
[in]cyY offset of image pivot (you can also use one of the gdl::AlignmentModes).
[in]scaleScale of image (1.0f is original size).
[in]angleRotation angle in degrees.

◆ PutS()

void gdl::ImageWii::PutS ( short  x1,
short  y1,
short  x2,
short  y2,
Color4f col 
)

Draws an image as a stretchable rectangle.

Draws the image as a fully stretchable rectangle with optional color translation. This function must only be called between a gdl::PrepDisplay() and gdl::Display() pair and if no image is loaded in this class, nothing is drawn.

Parameters
[in]x1Upper-left X coordinate of image.
[in]y1Upper-left Y coordinate of image.
[in]x2Lower-right X coordinate of image.
[in]y2Lower-right Y coordinate of image.
[in]colColor of image (use gdl::Color::White or full white with RGBA() for normal colors).

◆ Xsize()

short gdl::ImageWii::Xsize ( )

Returns the X size of the image in pixels.

Returns
X size of image in pixels.

◆ Ysize()

short gdl::ImageWii::Ysize ( )

Returns the Y size of the image in pixels.

Returns
Y size of image in pixels.

The documentation for this class was generated from the following files: