1 // 2 // Cross-platform free Puyo-Puyo clone. 3 // Copyright (C) 2006, 2007 Emma's Software 4 // 5 // This program is free software; you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation; either version 2 of the License, or 8 // (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with this program; if not, write to the Free Software 17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 // 19 #if !defined (AMOEBAX_SURFACE_H) 20 #define AMOEBAX_SURFACE_H 21 22 #include <string> 23 24 // Forward declarations. 25 struct SDL_Surface; 26 27 namespace Amoebax 28 { 29 /// 30 /// \class Surface. 31 /// \brief Holds an image surface. 32 /// 33 class Surface 34 { 35 public: 36 /// The maximum value the alpha component can take. 37 const static uint8_t k_MaxAlpha = 255; 38 39 Surface (void); 40 Surface (const Surface &surface); 41 ~Surface (void); 42 43 void blit (SDL_Surface *destination); 44 void blit (uint16_t destinationX, uint16_t destinationY, 45 SDL_Surface *destination); 46 void blit (uint16_t sourceX, uint16_t sourceY, 47 uint16_t sourceWidth, uint16_t sourceHeight, 48 uint16_t destinationX, uint16_t destinationY, 49 SDL_Surface *destination); 50 uint32_t getPixel (uint16_t x, uint16_t y); 51 static Surface *fromFile (const std::string fileName); 52 static Surface *fromScreen (void); 53 uint16_t getHeight (void) const; 54 uint16_t getWidth (void) const; 55 Surface &operator= (const Surface &surface); 56 void resize (float scaleFactor); 57 void setAlpha (uint8_t alpha); 58 void setColorKey (uint32_t colorKey); 59 static void swap (Surface &lhs, Surface &rhs); 60 SDL_Surface *toSDLSurface (void) const; 61 62 private: 63 Surface (SDL_Surface *SDLSurface); 64 65 /// The real image's SDL surface. 66 SDL_Surface *m_SDLSurface; 67 }; 68 69 /// 70 /// \brief Returns the Surface's SDL_Surface pointer. 71 /// 72 /// \return The pointer to SDL_Surface that represents this surface. 73 /// \note This surface must not be manually deleted. 74 /// 75 inline SDL_Surface * toSDLSurface(void)76 Surface::toSDLSurface (void) const 77 { 78 return m_SDLSurface; 79 } 80 } 81 82 #endif // !AMOEBAX_SURFACE_H 83