git repos / blockattack-game

source/code/CppSdl/CppSdlImageHolder.hpp

browsing at commit = 8d488d32e8da83a97d69ea67a3d96305a7f7243a

raw · blame · history

/* 
 * File:   CppSdlImageHolder.hpp
 * Author: poul
 *
 * Created on 29. september 2010, 19:46
 */

#ifndef _CPPSDLIMAGEHOLDER_HPP
#define	_CPPSDLIMAGEHOLDER_HPP

#include "SDL.h"
#include <string>
#include "CppSdlException.hpp"

namespace CppSdl {

class CppSdlImageHolder {
public:
    CppSdlImageHolder();
    CppSdlImageHolder(std::string filename);
    CppSdlImageHolder(const CppSdlImageHolder& orig);
    CppSdlImageHolder(char *rawdata, int datasize);
    virtual ~CppSdlImageHolder();
    SDL_Surface *GetRawDataInsecure();
    CppSdlImageHolder & operator=(const CppSdlImageHolder &rhs);
    void Cut(Uint32 x,Uint32 y,Sint32 w,Sint32 h);
    Uint32 GetWidth();
    Uint32 GetHeight();
    void PaintTo(SDL_Surface *target, int x, int y);
    void OptimizeForBlit(bool allowAlpha = true);
    bool IsNull();
    void MakeNull();
private:
    void Initialized(); //throws an exception if *data is null
    int *counter;
    SDL_Rect area;
    SDL_Surface *data;
};

}
#endif	/* _CPPSDLIMAGEHOLDER_HPP */