| 1 |
/* |
| 2 |
* Copyright (C) 2004 Ivo Danihelka ([email protected]) |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License as published by |
| 6 |
* the Free Software Foundation; either version 2 of the License, or |
| 7 |
* (at your option) any later version. |
| 8 |
*/ |
| 9 |
#include "Picture.h" |
| 10 |
|
| 11 |
#include "ResImagePack.h" |
| 12 |
|
| 13 |
//----------------------------------------------------------------- |
| 14 |
/** |
| 15 |
* Load surface. |
| 16 |
*/ |
| 17 |
Picture::Picture(const Path &file, const V2 &loc) |
| 18 |
: m_loc(loc) |
| 19 |
{ |
| 20 |
m_surface = ResImagePack::loadImage(file); |
| 21 |
} |
| 22 |
//----------------------------------------------------------------- |
| 23 |
/** |
| 24 |
* Use this surface. |
| 25 |
*/ |
| 26 |
Picture::Picture(SDL_Surface *new_surface, const V2 &loc) |
| 27 |
: m_loc(loc) |
| 28 |
{ |
| 29 |
m_surface = new_surface; |
| 30 |
} |
| 31 |
|
| 32 |
//----------------------------------------------------------------- |
| 33 |
/** |
| 34 |
* Free surface. |
| 35 |
*/ |
| 36 |
Picture::~Picture() |
| 37 |
{ |
| 38 |
SDL_FreeSurface(m_surface); |
| 39 |
} |
| 40 |
//----------------------------------------------------------------- |
| 41 |
void |
| 42 |
Picture::changePicture(const Path &file) |
| 43 |
{ |
| 44 |
SDL_FreeSurface(m_surface); |
| 45 |
m_surface = ResImagePack::loadImage(file); |
| 46 |
} |
| 47 |
//----------------------------------------------------------------- |
| 48 |
void |
| 49 |
Picture::changePicture(SDL_Surface *new_surface) |
| 50 |
{ |
| 51 |
SDL_FreeSurface(m_surface); |
| 52 |
m_surface = new_surface; |
| 53 |
} |
| 54 |
//----------------------------------------------------------------- |
| 55 |
/** |
| 56 |
* Blit entire surface to [x,y]. |
| 57 |
*/ |
| 58 |
void |
| 59 |
Picture::drawOn(SDL_Surface *screen) |
| 60 |
{ |
| 61 |
SDL_Rect rect; |
| 62 |
rect.x = m_loc.getX(); |
| 63 |
rect.y = m_loc.getY(); |
| 64 |
|
| 65 |
SDL_BlitSurface(m_surface, NULL, screen, &rect); |
| 66 |
} |
| 67 |
|
| 68 |
|