sdlimage.h

00001 /***************************************************************************
00002  *   Copyright (C) 2005-2008 by the FIFE team                              *
00003  *   http://www.fifengine.de                                               *
00004  *   This file is part of FIFE.                                            *
00005  *                                                                         *
00006  *   FIFE is free software; you can redistribute it and/or                 *
00007  *   modify it under the terms of the GNU Lesser General Public            *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2.1 of the License, or (at your option) any later version.    *
00010  *                                                                         *
00011  *   This library is distributed in the hope that it will be useful,       *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00014  *   Lesser General Public License for more details.                       *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Lesser General Public      *
00017  *   License along with this library; if not, write to the                 *
00018  *   Free Software Foundation, Inc.,                                       *
00019  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
00020  ***************************************************************************/
00021 
00022 #ifndef FIFE_VIDEO_RENDERBACKENDS_SDL_SDLIMAGE_H
00023 #define FIFE_VIDEO_RENDERBACKENDS_SDL_SDLIMAGE_H
00024 
00025 // Standard C++ library includes
00026 
00027 // 3rd party library includes
00028 #include <SDL_video.h>
00029 
00030 // FIFE includes
00031 // These includes are split up in two parts, separated by one empty line
00032 // First block: files included from the FIFE root src directory
00033 // Second block: files included from the same folder
00034 #include "video/image.h"
00035 
00036 namespace FIFE {
00037 
00040     class SDLImage : public Image {
00041     public:
00042         SDLImage(SDL_Surface* surface);
00043         SDLImage(const uint8_t* data, unsigned int width, unsigned int height);
00044         virtual ~SDLImage();
00045         void render(const Rect& rect, SDL_Surface* dst, unsigned char alpha = 255);
00046         void saveImage(const std::string& filename);
00047         bool putPixel(int x, int y, int r, int g, int b);
00048         void drawLine(const Point& p1, const Point& p2, int r, int g, int b);
00049         void drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4,  int r, int g, int b);
00050         void drawVertex(const Point& p, const uint8_t size, int r, int g, int b);
00051 
00052     protected:
00053         void setClipArea(const Rect& cliparea, bool clear);
00054 
00055     private:
00056         // Call this before rendering
00057         void finalize();
00058 
00064         SDL_Surface* optimize(SDL_Surface* surface);
00065 
00066         void resetSdlimage();
00067 
00068         // SDLSurface used to create the SDLImage.
00069         Uint8 m_last_alpha;
00070         // Is the surface already optimized for rendering
00071         bool m_finalized;
00072         SDL_Color m_colorkey;
00073     };
00074 
00075 }
00076 
00077 #endif
Generated by  doxygen 1.6.2-20100208