00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef INCL_IMAGEWIN
00027 #define INCL_IMAGEWIN 1
00028
00029
00030 #include "imagebuf.h"
00031 #include "exult_types.h"
00032 #include <string>
00033
00034 struct SDL_Surface;
00035 struct SDL_RWops;
00036
00037 #ifdef HAVE_OPENGL
00038 #define IF_OPENGL(a,b) if (scaler == OpenGL) a; else b
00039 #else
00040 #define IF_OPENGL(a,b) b
00041 #endif
00042
00043
00044
00045
00046
00047
00048 class Image_window
00049 {
00050 public:
00051
00052
00053
00054 #ifdef HAVE_OPENGL
00055 enum ScalerType {
00056 point = 0,
00057 interlaced = 1,
00058 bilinear = 2,
00059 BilinearPlus = 3,
00060 SaI = 4,
00061 SuperEagle = 5,
00062 Super2xSaI = 6,
00063 Scale2x = 7,
00064 OpenGL = 8,
00065
00066 NoScaler = -1,
00067 NumScalers = 9
00068 };
00069 #else
00070 enum ScalerType {
00071 point = 0,
00072 interlaced = 1,
00073 bilinear = 2,
00074 BilinearPlus = 3,
00075 SaI = 4,
00076 SuperEagle = 5,
00077 Super2xSaI = 6,
00078 Scale2x = 7,
00079 OpenGL = 8,
00080
00081 NoScaler = -1,
00082 NumScalers = 8
00083 };
00084 #endif
00085
00086
00087 static const char *ScalerNames[];
00088 static ScalerType get_scaler_for_name(const std::string &name);
00089 inline static const char *get_name_for_scaler(int num) { return ScalerNames[num]; }
00090
00091 protected:
00092 Image_buffer *ibuf;
00093 int scale;
00094 int scaler;
00095 bool uses_palette;
00096 bool fullscreen;
00097 SDL_Surface *surface;
00098 SDL_Surface *scaled_surface;
00099 SDL_Surface *unscaled_surface;
00100
00101 void (Image_window::*show_scaled)(int x, int y, int w, int h);
00102
00103
00104
00105 void show_scaled8to16_2xSaI(int x, int y, int w, int h);
00106 void show_scaled8to555_2xSaI(int x, int y, int w, int h);
00107 void show_scaled8to565_2xSaI(int x, int y, int w, int h);
00108 void show_scaled8to32_2xSaI(int x, int y, int w, int h);
00109 void show_scaled8to16_Super2xSaI(int x, int y, int w, int h);
00110 void show_scaled8to555_Super2xSaI(int x, int y, int w, int h);
00111 void show_scaled8to565_Super2xSaI(int x, int y, int w, int h);
00112 void show_scaled8to32_Super2xSaI(int x, int y, int w, int h);
00113
00114 void show_scaled8to16_bilinear(int x, int y, int w, int h);
00115 void show_scaled8to555_bilinear(int x, int y, int w, int h);
00116 void show_scaled8to565_bilinear(int x, int y, int w, int h);
00117 void show_scaled8to32_bilinear(int x, int y, int w, int h);
00118 void show_scaled8to16_SuperEagle(int x, int y, int w, int h);
00119 void show_scaled8to555_SuperEagle(int x, int y, int w, int h);
00120 void show_scaled8to565_SuperEagle(int x, int y, int w, int h);
00121 void show_scaled8to32_SuperEagle(int x, int y, int w, int h);
00122 void show_scaled_point(int x, int y, int w, int h);
00123 void show_scaled_interlace(int x, int y, int w, int h);
00124 void show_scale2x_noblur(int x, int y, int w, int h);
00125 void show_scaled8to16_BilinearPlus(int x, int y, int w, int h);
00126 void show_scaled8to555_BilinearPlus(int x, int y, int w, int h);
00127 void show_scaled8to565_BilinearPlus(int x, int y, int w, int h);
00128 void show_scaled8to32_BilinearPlus(int x, int y, int w, int h);
00129 void show_scaledOpenGL(int x, int y, int w, int h);
00130
00131
00132
00133
00134 void create_surface(unsigned int w, unsigned int h);
00135 void free_surface();
00136 bool try_scaler(int w, int h, uint32 flags);
00137 public:
00138
00139 Image_window(Image_buffer *ib, int scl = 1, bool fs = false, int sclr = point)
00140 : ibuf(ib), scale(scl), scaler(sclr), uses_palette(true),
00141 fullscreen(fs), surface(0),
00142 scaled_surface(0), show_scaled(0)
00143 { create_surface(ibuf->width, ibuf->height); }
00144 virtual ~Image_window();
00145 int get_scale()
00146 { return scale; }
00147 int get_scaler()
00148 { return scaler; }
00149 bool is_palettized()
00150 { return uses_palette; }
00151
00152
00153 int is_visible(int x, int y, int w, int h)
00154 { return ibuf->is_visible(x, y, w, h); }
00155
00156 void set_title(const char *title);
00157
00158 Image_buffer *get_ibuf()
00159 { return ibuf; }
00160 int get_width()
00161 { return ibuf->width; }
00162 int get_height()
00163 { return ibuf->height; }
00164 int ready()
00165 { return (ibuf->bits != 0); }
00166 bool is_fullscreen() { return fullscreen; }
00167
00168 Image_buffer *create_buffer(int w, int h);
00169
00170 void resized(unsigned int neww, unsigned int nehh, int newsc, int newscaler = point);
00171 void show();
00172
00173 void show(int x, int y, int w, int h);
00174
00175 void toggle_fullscreen();
00176
00177 virtual void set_palette(unsigned char *rgbs, int maxval,
00178 int brightness = 100)
00179 { }
00180
00181 virtual void rotate_colors(int first, int num, int upd)
00182 { }
00183
00184
00185
00186
00187 void fill16(unsigned short pix)
00188 { ibuf->fill16(pix); }
00189
00190 void fill16(unsigned short pix, int srcw, int srch,
00191 int destx, int desty)
00192 { ibuf->fill16(pix, srcw, srch, destx, desty); }
00193
00194 void copy16(unsigned short *src_pixels,
00195 int srcw, int srch, int destx, int desty)
00196 { ibuf->copy16(src_pixels, srcw, srch, destx, desty); }
00197
00198 void copy_transparent16(unsigned char *src_pixels, int srcw,
00199 int srch, int destx, int desty)
00200 { ibuf->copy_transparent16(src_pixels, srcw, srch,
00201 destx, desty); }
00202
00203
00204
00205
00206 void fill8(unsigned char val)
00207 { ibuf->fill8(val); }
00208
00209 void fill8(unsigned char val, int srcw, int srch,
00210 int destx, int desty)
00211 { IF_OPENGL(opengl_fill8(val, srcw, srch, destx, desty),
00212 ibuf->fill8(val, srcw, srch, destx, desty)); }
00213
00214 void fill_line8(unsigned char val, int srcw,
00215 int destx, int desty)
00216 { ibuf->fill_line8(val, srcw, destx, desty); }
00217
00218 void copy8(unsigned char *src_pixels,
00219 int srcw, int srch, int destx, int desty)
00220 { ibuf->copy8(src_pixels, srcw, srch, destx, desty); }
00221
00222 void copy_line8(unsigned char *src_pixels, int srcw,
00223 int destx, int desty)
00224 { ibuf->copy_line8(src_pixels, srcw, destx, desty); }
00225
00226 void copy_line_translucent8(
00227 unsigned char *src_pixels, int srcw,
00228 int destx, int desty, int first_translucent,
00229 int last_translucent, Xform_palette *xforms)
00230 { ibuf->copy_line_translucent8(src_pixels, srcw, destx, desty,
00231 first_translucent, last_translucent, xforms); }
00232
00233 void fill_line_translucent8(unsigned char val,
00234 int srcw, int destx, int desty, Xform_palette& xform)
00235 { ibuf->fill_line_translucent8(val, srcw, destx, desty,
00236 xform); }
00237
00238 virtual void fill_translucent8(unsigned char val, int srcw, int srch,
00239 int destx, int desty, Xform_palette& xform)
00240 { IF_OPENGL(opengl_fill_translucent8(val, srcw, srch,
00241 destx, desty, xform), ibuf->fill_translucent8(val,
00242 srcw, srch, destx, desty, xform)); }
00243
00244 void copy_transparent8(unsigned char *src_pixels, int srcw,
00245 int srch, int destx, int desty)
00246 { ibuf->copy_transparent8(src_pixels, srcw, srch,
00247 destx, desty); }
00248
00249
00250
00251 #ifdef HAVE_OPENGL
00252
00253 void opengl_fill8(unsigned char val, int srcw, int srch,
00254 int destx, int desty);
00255 virtual void opengl_fill_translucent8(unsigned char val,
00256 int srcw, int srch, int destx, int desty, Xform_palette& xform);
00257 #endif
00258
00259
00260
00261 void clear_clip()
00262 { ibuf->clear_clip(); }
00263
00264 void set_clip(int x, int y, int w, int h)
00265 { ibuf->set_clip(x, y, w, h); }
00266
00267 void copy(int srcx, int srcy, int srcw, int srch,
00268 int destx, int desty)
00269 { ibuf->copy(srcx, srcy, srcw, srch, destx, desty); }
00270
00271 void get(Image_buffer *dest, int srcx, int srcy)
00272 { ibuf->get(dest, srcx, srcy); }
00273
00274 void put(Image_buffer *src, int destx, int desty)
00275 { ibuf->put(src, destx, desty); }
00276
00277 bool screenshot(SDL_RWops *dst);
00278 };
00279
00280
00281 #endif