// // C++ Implementation: %{MODULE} // // Description: // // // Author: %{AUTHOR} <%{EMAIL}>, (C) %{YEAR} // // Copyright: See COPYING file that comes with this distribution // // #include "image.h" #include namespace SDLwidgets { Image::Image( const char* filename ) { _image_surface = IMG_Load( filename ); _width = _image_surface->w; _min_width = _image_surface->w; _height = _image_surface->h; _min_height = _image_surface->h; } Image::Image( Uint32 width, Uint32 height ) { SDL_PixelFormat* format = SDL_GetVideoSurface()->format; _image_surface = SDL_CreateRGBSurface( SDL_SWSURFACE, width, height, format->BitsPerPixel, format->Rmask, format->Gmask, format->Bmask, format->Amask ); _width = _image_surface->w; _min_width = _image_surface->w; _height = _image_surface->h; _min_height = _image_surface->h; } void Image::draw( SDL_Surface* surface ) { SDL_Rect dest_rect; getOffset( dest_rect.x, dest_rect.y ); SDL_BlitSurface( _image_surface, 0, surface, &dest_rect ); } }