Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

Picture.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004 Ivo Danihelka (ivo@danihelka.net)
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  */
00009 #include "Picture.h"
00010 
00011 #include "ResImagePack.h"
00012 
00013 //-----------------------------------------------------------------
00014 /**
00015  * Load surface.
00016  */
00017 Picture::Picture(const Path &file, const V2 &loc)
00018     : m_loc(loc)
00019 {
00020     m_surface = ResImagePack::loadImage(file);
00021 }
00022 //-----------------------------------------------------------------
00023 /**
00024  * Use this surface.
00025  */
00026 Picture::Picture(SDL_Surface *new_surface, const V2 &loc)
00027     : m_loc(loc)
00028 {
00029     m_surface = new_surface;
00030 }
00031 
00032 //-----------------------------------------------------------------
00033 /**
00034  * Free surface.
00035  */
00036 Picture::~Picture()
00037 {
00038     SDL_FreeSurface(m_surface);
00039 }
00040 //-----------------------------------------------------------------
00041 void
00042 Picture::changePicture(const Path &file)
00043 {
00044     SDL_FreeSurface(m_surface);
00045     m_surface = ResImagePack::loadImage(file);
00046 }
00047 //-----------------------------------------------------------------
00048 void
00049 Picture::changePicture(SDL_Surface *new_surface)
00050 {
00051     SDL_FreeSurface(m_surface);
00052     m_surface = new_surface;
00053 }
00054 //-----------------------------------------------------------------
00055 /**
00056  * Blit entire surface to [x,y].
00057  */
00058 void
00059 Picture::drawOn(SDL_Surface *screen)
00060 {
00061     SDL_Rect rect;
00062     rect.x = m_loc.getX();
00063     rect.y = m_loc.getY();
00064 
00065     SDL_BlitSurface(m_surface, NULL, screen, &rect);
00066 }
00067 
00068 

Generated on Wed Jun 1 09:54:31 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2