CRM32Pro SDK  v5.22
List of all members | Public Member Functions

IImage. More...

Detailed Description

IImage.

Interface to manage images.

Public Member Functions

int isBMP (const char *file)
 Check if the given file is a BMP. More...
 
int isPNG (const char *file)
 Check if the given file is a PNG. More...
 
SDL_Surface * Load (char *fileDPF, char *imgname, sHeaderIPF *header=NULL)
 Load an IPF from a DPF(using a filename) More...
 
SDL_Surface * Load (int idDPF, char *imgname, sHeaderIPF *header=NULL)
 Load an IPF from a DPF(using an idDPF) More...
 
SDL_Surface * LoadBMP (const char *filename)
 Load a BMP. More...
 
SDL_Surface * LoadIMG (const char *filename)
 Load an image (BMP or PNG) More...
 
SDL_Surface * LoadPNG (const char *filename)
 Load a PNG from an external file. More...
 
SDL_Surface * LoadPNG (void *mem, int size)
 Load a PNG from a memory block. More...
 
int Save (char *fileDPF, char *imgname, SDL_Surface *image)
 Save a surface into a DPF. More...
 
int Save (int idDPF, char *imgname, SDL_Surface *image)
 Save a surface into a DPF. More...
 
int SaveBMP (char *filename, SDL_Surface *surface)
 Save a given surface in an external BMP file. More...
 
int SavePNG (char *filename, SDL_Surface *surface, int compression=IIMAGE_PNGCOMPRESS_DEFAULT)
 Save a given surface in an external PNG file. More...
 

Member Function Documentation

int CRM32Pro_IImage::isBMP ( const char *  filename)

Check if the given file is a BMP.

Parameters
filenameName of the BMP
Returns
0 It is not a BMP
1 It is a BMP
int CRM32Pro_IImage::isPNG ( const char *  filename)

Check if the given file is a PNG.

Parameters
filenameName of the PNG
Returns
0 It is not a PNG
1 It is a PNG
SDL_Surface * CRM32Pro_IImage::Load ( char *  fileDPF,
char *  imgname,
sHeaderIPF header = NULL 
)

Load an IPF from a DPF(using a filename)

Parameters
fileDPFName of the DPF
imgnameImage name stored in the DPF
headerDeprecated. NULL by default. Pointer to an IPF header which will be filled up with the image info.
Returns
NULL Failed
Any other value, a pointer to the converted surface to the screen format(if available)
Examples:
Example01_BasicCode.cpp, Example03_GUI.cpp, Example05_VideoPlayer.cpp, Example08_SpriteCollision.cpp, Example09_LogicRenderRates.cpp, Example12_DRTS.cpp, and SpacePong.cpp.
SDL_Surface * CRM32Pro_IImage::Load ( int  idDPF,
char *  imgname,
sHeaderIPF header = NULL 
)

Load an IPF from a DPF(using an idDPF)

Parameters
idDPFID of the opened DPF
imgnameImage name stored in the DPF
headerDeprecated. NULL by default. Pointer to an IPF header which will be filled up with the image info.
Returns
NULL Failed
Any other value, a pointer to the converted surface to the screen format(if available)
SDL_Surface * CRM32Pro_IImage::LoadBMP ( const char *  filename)

Load a BMP.

If you do not want to auto convert the BMP surface to current screen format, you must use SDL_LoadBMP().

Parameters
filenameName of the BMP
Returns
a converted surface to the screen format(if available)
SDL_Surface * CRM32Pro_IImage::LoadIMG ( const char *  filename)

Load an image (BMP or PNG)

It will try to open a BMP or a PNG and will convert the surface to the current screen format(if any).
It fully supports alpha per pixel PNGs.

Parameters
filenameName of the BMP or PNG
Returns
a converted surface to the screen format(if available)
SDL_Surface * CRM32Pro_IImage::LoadPNG ( const char *  filename)

Load a PNG from an external file.

It will try to convert the surface to the current screen format(if any). It fully supports alpha per pixel PNGs.

Parameters
filenameName of the PNG
Returns
a converted surface to the screen format(if available)
SDL_Surface * CRM32Pro_IImage::LoadPNG ( void *  mem,
int  size 
)

Load a PNG from a memory block.

It will try to convert the surface to the current screen format(if any). It fully supports alpha per pixel PNGs.

Parameters
memPointer to the memory block that contains the PNG
sizeSize of the memory block
Returns
a converted surface to the screen format(if available)
int CRM32Pro_IImage::Save ( char *  fileDPF,
char *  imgname,
SDL_Surface *  image 
)

Save a surface into a DPF.

Parameters
fileDPFname and optional path of a DPF to store this image
imgnameDesired name to store your image in the DPF
imagePointer to a SDL_surface with your surface
Returns
-1 Image already exists.
0 Failed.
any other positive value, Ok and packed size of the added image
int CRM32Pro_IImage::Save ( int  idDPF,
char *  imgname,
SDL_Surface *  srcimage 
)

Save a surface into a DPF.

Parameters
idDPFID of the opened DPF
imgnameDesired name to store your image in the DPF
srcimagePointer to a SDL_surface with your surface
Returns
-1 Image already exists.
0 Failed.
any other positive value, Ok and packed size of the added image
int CRM32Pro_IImage::SaveBMP ( char *  filename,
SDL_Surface *  surface 
)

Save a given surface in an external BMP file.

If a BMP already exists, it will be replaced with the new one.

Parameters
filenameName and optional path of the BMP
surfacePointer to a SDL_surface with your surface
Returns
0 Failed
1 Ok
int CRM32Pro_IImage::SavePNG ( char *  filename,
SDL_Surface *  surface,
int  compression = IIMAGE_PNGCOMPRESS_DEFAULT 
)

Save a given surface in an external PNG file.

If a PNG already exists, it will be replaced with the new one.

Parameters
filenameName of the PNG
surfacePointer to a SDL_surface with your surface
compressionSet desired compression value. From 0(minimum) to 9(maximum). By default, it is -1 (let pnglib chooses the level).
Returns
0 Failed
1 Ok

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