Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

image.h

Go to the documentation of this file.
00001 // OMICRON ENGINE HEADER FILE
00002 //
00003 // --------------------------------------------------------------------------
00004 // Copyright (C) 2001-2002 by Bjoern Paetzel <kolrabi@gmx.de>
00005 //
00006 // This file is part of the Omicron Engine.
00007 //
00008 // The Omicron Engine is free software; you can redistribute it and/or modify
00009 // it under the terms of the  GNU General Public License  as published by the
00010 // Free Software Foundation;  either version  2  of the License,  or (at your
00011 // option) any later version.
00012 //
00013 // The Omicron Engine  is distributed in the hope that it will be useful, but
00014 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00015 // or  FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
00016 // for more details.
00017 //
00018 // You should have  received a copy of the  GNU General Public License  along
00019 // with The Omicron Engine;  if not,  write to the  Free Software Foundation,
00020 // Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
00021 //
00022 // --------------------------------------------------------------------------
00023 // Last modified:       $Date: 2002/12/07 19:02:17 $
00024 // By           :       $Author: kolrabi $
00025 // $Id: image.h,v 1.1.1.1 2002/12/07 19:02:17 kolrabi Exp $ 
00026 
00027 /*
00028 
00029   $Log: image.h,v $
00030   Revision 1.1.1.1  2002/12/07 19:02:17  kolrabi
00031   initial release
00032 
00033 
00034 */
00035 
00043 #include            "forward.h"
00044 #include "omicron.h"    // Hinzugefügt von der Klassenansicht
00045 
00046 /**************************************************************************** 
00047  **************************************************************************** 
00048  * DEFINES ****************************************************************** 
00049  **************************************************************************** 
00050  ****************************************************************************/ 
00051  
00052 /* IMAGE TYPES **************************************************************/ 
00053 #define             IMAGE_TGA                   1 
00054 // #define         IMAGE_BMP                   2 
00055 // #define         IMAGE_JPG                   3
00056 // #define         IMAGE_PNG                   4
00057 
00058 #define             ANIM_ONESHOT                1
00059 #define             ANIM_LOOP                   2
00060 #define             ANIM_PINGPONG               3
00061  
00062 /**************************************************************************** 
00063  **************************************************************************** 
00064  * TYPES ******************************************************************** 
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     // manipulations
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 // inlines
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

Generated on Wed Dec 18 15:48:46 2002 for omicron engine by doxygen1.2.18