00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00043 #include "forward.h"
00044 #include "omicron.h"
00045
00046
00047
00048
00049
00050
00051
00052
00053 #define IMAGE_TGA 1
00054
00055
00056
00057
00058 #define ANIM_ONESHOT 1
00059 #define ANIM_LOOP 2
00060 #define ANIM_PINGPONG 3
00061
00062
00063
00064
00065
00066
00067
00068 #ifndef OMICRON_TYPES_IMAGE_DEFINED
00069 #define OMICRON_TYPES_IMAGE_DEFINED
00070
00075 class image_c
00076 {
00077
00078 protected:
00079 void update_tex();
00080
00081 friend class texture_manager_c;
00082
00083 ushort width;
00084 ushort height;
00085
00086 char *buf;
00087 ulong buflen;
00088
00089 bool hasalpha;
00090
00091 char bpp;
00092
00094 bool
00095 load_tga_rgb(struct file_s *file);
00096
00098 bool
00099 load_tga_rgbrle(struct file_s *file);
00100
00101 bool
00102 load_tga(const char *filename);
00103
00110 bool
00111 prepare_blt(image_c *src, sshort &sx, sshort &sy,
00112 sshort &x, sshort &y, sshort &w, sshort &h);
00113 public:
00114 sshort tex;
00115 bool dirty;
00116
00117 image_c();
00118 virtual ~image_c();
00119
00125 virtual void
00126 create(ushort x, ushort y);
00127
00132 virtual bool
00133 load(const char *filename);
00134
00139 void
00140 copy(image_c *src);
00141
00148 void
00149 draw(ushort x, ushort y);
00150
00151 inline ushort
00152 get_width() const;
00153
00154 inline ushort
00155 get_height() const;
00156
00157 virtual inline const char *
00158 get_pixels() const;
00159
00160 inline ulong
00161 get_buffer_len() const;
00162
00163 inline char
00164 get_bpp() const;
00165
00166 inline bool
00167 get_has_alpha() const;
00168
00169
00170
00176 void
00177 stamp(image_c *src, sshort x, sshort y);
00178
00184 void
00185 blt(image_c *src, sshort sx, sshort sy,
00186 sshort x, sshort y, sshort w, sshort h);
00187
00192 void
00193 blt_blend(image_c *src, sshort sx, sshort sy,
00194 sshort x, sshort y, sshort w, sshort h, sshort blendtype);
00195
00201 void
00202 color_blend(image_c *src, sshort sx, sshort sy,
00203 sshort x, sshort y, sshort w, sshort h, color_t color);
00204
00209 void
00210 crop(sshort x, sshort y, sshort w, sshort h);
00211
00216 void
00217 set_pixel(sshort x, sshort y, color_t color);
00218
00223 color_t
00224 get_pixel(sshort x, sshort y);
00225
00230 void
00231 vline(sshort x, sshort y, sshort h, color_t color);
00232
00237 void
00238 hline(sshort x, sshort y, sshort w, color_t color);
00239
00244 void
00245 line(sshort x, sshort y, sshort w, sshort h, color_t color);
00246
00251 void
00252 rectangle(sshort x, sshort y, sshort w, sshort h, color_t color);
00253
00258 void
00259 filled_rectangle(sshort x, sshort y, sshort w, sshort h, color_t color);
00260
00265 sshort
00266 draw_char(sshort x, sshort y, uchar c, struct font_s *fnt, color_t color);
00267
00272 sshort
00273 draw_string(sshort x, sshort y, const char *c, struct font_s *fnt, color_t color);
00274
00279 void
00280 mirror_vertical();
00281
00286 void
00287 rgb2yuv();
00288
00293 void
00294 yuv2rgb();
00295 };
00296
00297
00298
00300 inline ushort image_c::get_width() const
00301 {
00302 AssertThisV; return width;
00303 }
00304
00306 inline ushort image_c::get_height() const
00307 {
00308 AssertThisV; return height;
00309 }
00310
00312 inline const char *image_c::get_pixels() const
00313 {
00314 AssertThisV; return buf;
00315 }
00316
00318 inline ulong image_c::get_buffer_len() const
00319 {
00320 AssertThisV; return buflen;
00321 }
00322
00324 inline char image_c::get_bpp() const
00325 {
00326 AssertThisV; return bpp;
00327 }
00328
00330 inline bool image_c::get_has_alpha() const
00331 {
00332 AssertThisV; return hasalpha;
00333 }
00334
00344 class animation_c:public image_c
00345 {
00346 protected:
00347
00348 ushort framecount;
00349 ushort fps;
00350 sshort frame;
00351
00352 ulong nextframetime;
00353
00354 image_c *img;
00355
00356 sshort playdir;
00357 sshort playtype;
00358
00359 public:
00360
00361 animation_c();
00362 virtual ~animation_c();
00363
00370 void
00371 set_framecount(ushort f);
00372
00378 image_c *
00379 set_frame(ushort f);
00380
00386 bool
00387 load(char *filename);
00388
00393 void
00394 set_fps(ushort f);
00395
00404 void
00405 play(sshort type);
00406
00411 void
00412 stop();
00413
00418 const char *
00419 get_pixels();
00420 };
00421
00422 #endif