Files
SDLPongCPP/TrooperEngineDLL/TrooperEngine/VideoEngine/cImage.hpp
T

101 lines
3.2 KiB
C++

#ifndef _CIMAGE_HPP_
#define _CIMAGE_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
#include <SDL_image.h>
/*** DLL Header File ***/
#include "dllExport.h"
/*** Custom Header Files ***/
#include "../UtilityEngine/cString.hpp"
using UtilityEngine::cString;
namespace VideoEngine {
/* cImage holds a SDL_Texture or SDL_Surface for use by a cSprite or cAnimatedSprite */
class EXPORT_FROM_MYDLL cImage
{
public:
cImage( const bool transparent = false, const unsigned char red = 0, const unsigned char blue = 0, const unsigned char green = 255,
const unsigned char translevel = 255, const bool isSurface = false );
cImage( SDL_Surface* surface );
cImage( SDL_Texture* texture );
/* Copy constructor */
cImage( const cImage& copy, const bool surfaceCopy = true );
~cImage();
/* Saves the Image to a BMP file */
void SaveImage( const cString& fileName, const cString& dir = "" );
/* Creates a New Image based on input */
const cImage* NewImage( SDL_Rect& area ) const;
/// Sets
/* Sets Transparent on if set to true */
void setTransparent( const bool transparent = true );
/* Sets the colour to be made transparent */
void setColourTrans( const unsigned char red = 0, const unsigned char blue = 0, const unsigned char green = 255 );
/* Sets the level of the transparent 255 = clear, 0 = solid */
void setLevelTrans( const unsigned char translevel = 255 );
/// Gets
/* Gets a pointer to the SDL_Surface */
SDL_Surface* getSurface() const;
/* Gets a pointer to the SDL_Texture */
SDL_Texture* getTexture() const;
/* Gets a pointer to the SDL_Texture */
SDL_Texture* getImage() const;
/* Gets the width of the image */
const unsigned long int getWidth() const;
/* Gets the Height of the image */
const unsigned long int getHeight() const;
/* Gets the Width and Height of the image */
const SDL_Rect getWH() const;
/* Gets the Width and Height of the image */
void getWH( unsigned long int& w, unsigned long int& h ) const;
/* Gets return true if transparent on false if off */
const bool getTransparent() const;
/* Gets return the colour to be made transparent */
void getColourTrans( unsigned char& red, unsigned char& blue, unsigned char& green ) const;
/* Gets the transparent red colour */
const unsigned char getRedTrans() const;
/* Gets the transparent blue colour */
const unsigned char getBlueTrans() const;
/* Gets the transparent green colour */
const unsigned char getGreenTrans() const;
/* Gets the transparent level 255 = clear, 0 = solid */
const unsigned char getLevelTrans() const;
const bool getIsSurface() const;
protected:
/* Protected so only derived class can access. *.
/* Sets the image to surface */
void setImage( SDL_Surface* surface );
void setImage( SDL_Texture* texture );
private:
/// Functions
void TransparentSetup();
void UnloadImage();
private:
/// Variables
SDL_Texture* mp_texture;/// = nullptr
SDL_Surface* mp_surface;/// = nullptr
bool m_transparent;/// = false
unsigned char m_transRed;/// = 0
unsigned char m_transBlue;/// = 0
unsigned char m_transGreen;/// = 255
unsigned char m_transLevel;/// = 255
bool m_isSurface;
};/// END CLASS DEFINITION cImage
}/// END NAMESPACE DEFINITION VideoEngine
#endif/// END IFNDEF _CIMAGE_HPP_