sdlimage.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef FIFE_VIDEO_RENDERBACKENDS_SDL_SDLIMAGE_H
00023 #define FIFE_VIDEO_RENDERBACKENDS_SDL_SDLIMAGE_H
00024
00025
00026
00027
00028 #include <SDL_video.h>
00029
00030
00031
00032
00033
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
00057 void finalize();
00058
00064 SDL_Surface* optimize(SDL_Surface* surface);
00065
00066 void resetSdlimage();
00067
00068
00069 Uint8 m_last_alpha;
00070
00071 bool m_finalized;
00072 SDL_Color m_colorkey;
00073 };
00074
00075 }
00076
00077 #endif