ibuf8.h

Go to the documentation of this file.
00001 /*
00002  *  ibuf8.h - 8-bit image buffer.
00003  *
00004  *  Copyright (C) 1998-1999  Jeffrey S. Freedman
00005  *  Copyright (C) 2000-2001  The Exult Team
00006  *
00007  *  This program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; either version 2 of the License, or
00010  *  (at your option) any later version.
00011  *
00012  *  This program is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *  GNU General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License
00018  *  along with this program; if not, write to the Free Software
00019  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00020  */
00021 
00022 #ifndef INCL_IBUF8
00023 #define INCL_IBUF8  1
00024 
00025 #include "imagebuf.h"
00026 
00027 /*
00028  *  An 8-bit image buffer:
00029  */
00030 class Image_buffer8 : public Image_buffer
00031   {
00032           // Private ctor. for Image_window8.
00033   Image_buffer8(unsigned int w, unsigned int h, Image_buffer *)
00034     : Image_buffer(w, h, 8)
00035     {  }
00036 public:
00037   Image_buffer8(unsigned int w, unsigned int h)
00038     : Image_buffer(w, h, 8)
00039     { bits = new unsigned char[w*h]; }
00040   friend class Image_window8;
00041   /*
00042    *  Depth-independent methods:
00043    */
00044   virtual Image_buffer *create_another(int w, int h)
00045     { return new Image_buffer8(w, h); }
00046           // Copy within itself.
00047   virtual void copy(int srcx, int srcy, int srcw, int srch, 
00048               int destx, int desty);
00049           // Get rect. into another buf.
00050   virtual void get(Image_buffer *dest, int srcx, int srcy);
00051           // Put rect. back.
00052   virtual void put(Image_buffer *src, int destx, int desty);
00053   
00054   virtual void fill_static(int black, int gray, int white);
00055 
00056   /*
00057    *  8-bit color methods:
00058    */
00059           // Fill with given (8-bit) value.
00060   virtual void fill8(unsigned char val);
00061           // Fill rect. wth pixel.
00062   virtual void fill8(unsigned char val, int srcw, int srch,
00063             int destx, int desty);
00064           // Fill line with pixel.
00065   virtual void fill_line8(unsigned char val, int srcw,
00066             int destx, int desty);
00067           // Copy rectangle into here.
00068   virtual void copy8(unsigned char *src_pixels,
00069         int srcw, int srch, int destx, int desty);
00070           // Copy line to here.
00071   virtual void copy_line8(unsigned char *src_pixels, int srcw,
00072             int destx, int desty);
00073           // Copy with translucency table.
00074   virtual void copy_line_translucent8(
00075     unsigned char *src_pixels, int srcw,
00076     int destx, int desty, int first_translucent,
00077     int last_translucent, Xform_palette *xforms);
00078           // Apply translucency to a line.
00079   virtual void fill_line_translucent8(unsigned char val,
00080       int srcw, int destx, int desty, Xform_palette& xform);
00081           // Apply translucency to a rectangle
00082   virtual void fill_translucent8(unsigned char val, int srcw, int srch, 
00083         int destx, int desty, Xform_palette& xform);
00084           // Copy rect. with transp. color.
00085   virtual void copy_transparent8(unsigned char *src_pixels, int srcw,
00086           int srch, int destx, int desty);
00087           // Get/put a single pixel.
00088   unsigned char get_pixel8(int x, int y)
00089     { return bits[y*line_width + x]; }
00090   void put_pixel8(unsigned char pix, int x, int y)
00091     { 
00092     if (x >= clipx && x < clipx + clipw &&
00093         y >= clipy && y < clipy + cliph)
00094       bits[y*line_width + x] = pix;
00095     }
00096 
00097   void paint_rle (int xoff, int yoff, unsigned char *in);
00098           // Convert to 32-bit rgba.
00099   unsigned char *rgba(unsigned char *pal, unsigned char transp, 
00100     int first_translucent = 256,
00101     int last_translucent = 256, Xform_palette *xforms = 0);
00102   };
00103 
00104 #endif

Generated on Mon Jul 9 14:42:47 2007 for ExultEngine by  doxygen 1.5.1