00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef __MX_SURFACE__H__
00017 #define __MX_SURFACE__H__
00018
00019 #include"mxf.h"
00020 #include<iostream>
00021 #include "mxtype.h"
00022
00023
00024 namespace mx
00025 {
00026
00027 using std::cout;
00029 typedef struct _mxPoint { int x; int y; } mxPoint;
00030
00032 class mxSurface {
00033
00034 public:
00035
00038 mxSurface(SDL_Surface *surface = 0);
00042 mxSurface(const mxSurface &c);
00044 virtual ~mxSurface();
00049 mxSurface& operator=(const mxSurface &c);
00054 mxSurface& operator=(SDL_Surface *surface);
00058 SDL_Surface *getSurface() const;
00062 SDL_Surface *surface() const { return object_surface; }
00066 void setCopySurface(SDL_Surface *surface);
00070 const int width() const;
00074 const int height() const;
00078 const int pitch() const;
00082 operator SDL_Surface *();
00086 operator SDL_PixelFormat *();
00095 mxPoint **buildResizeTable(int nw, int nh, int w, int h, mxPoint **buffer);
00096
00101 unsigned int &operator[](unsigned int pos);
00102
00103
00104
00109 void lockSurface();
00114 const bool isLocked() const;
00118 void unlockSurface();
00123 void *rawData();
00129 bool createSurface(int w, int h);
00134 bool createSurface( Size &s );
00135
00140 bool copyResizeSurface(const mxSurface &c);
00147 bool copyResizeSurface(const mxSurface &c, SDL_Rect *src, SDL_Rect *dst);
00154 bool copySurface(const mxSurface &c, SDL_Rect *source, SDL_Rect *dest);
00161 inline bool copySurface(const mxSurface &c, mx::Rect source, mx::Rect dest) { SDL_Rect src = { source.x(), source.y(), source.width(), source.height() }; SDL_Rect dst = { dest.x(), dest.y(), dest.width(), dest.height() }; return copySurface(c, &src, &dst); }
00169 bool copySurfaceColorKey(const mxSurface &c, SDL_Rect *source, SDL_Rect *dest, SDL_Color color_key);
00170
00172 void Flip() const;
00173
00177 virtual void noZero(bool noremove);
00179 void cleanSurface();
00180
00187 void updateRect(unsigned int x, unsigned int y, unsigned int w, unsigned int h) const;
00188
00190 void Clear() const;
00191
00196 const bool loadBitmapFromMemory(void *memory);
00203 inline const int linepos(const int x, const int y) const { return (x+(y*width())); }
00204
00208 Size size();
00209
00213 mxSurface *copySurface();
00214
00215 protected:
00217 SDL_Surface *object_surface;
00219 void clean_up();
00220 private:
00221 bool protected_noremove;
00222 mxPoint **p_buffer;
00223 bool is_locked;
00224 };
00225
00226 }
00227
00228 #endif
00229