/* $Id: wopbackground.cpp,v 1.7 2005/06/28 13:55:26 chfreund Exp $ */ #include "wopbackground.hpp" #include "loader.hpp" #include "global.hpp" /**********************************************************/ WopBackground::WopBackground( int width, int height, const char* filename, SDL_PixelFormat* format ) { Loader* loader = Loader::getInstance(); SDL_Surface* tile = loader->getImage( filename, false, true ); SDL_Surface* puzzle = SDL_CreateRGBSurface( SDL_SWSURFACE, width, height, format->BitsPerPixel, format->Rmask, format->Gmask, format->Bmask, format->Amask ); SDL_Rect rect; rect.x = rect.y = 0; while ( rect.y < height ) { while ( rect.x < width ) { SDL_BlitSurface( tile, 0, puzzle, &rect ); rect.x += tile->w; } rect.y += tile->h; rect.x = 0; } m_graphic = SDL_DisplayFormat( puzzle ); SDL_FreeSurface( puzzle ); } /**********************************************************/ WopBackground::~WopBackground() { LOG( 1 ) INFO( "WopBackground::~WopBackground: starting destructor\n" ); SDL_FreeSurface( m_graphic ); LOG( 1 ) INFO( "WopBackground::~WopBackground: done\n" ); }