Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

Bitmap.h

Go to the documentation of this file.
00001 // This file is part of dvi2bitmap. 00002 // Copyright 1999--2002, Council for the Central Laboratory of the Research Councils 00003 // 00004 // This program is part of the Starlink Software Distribution: see 00005 // http://www.starlink.ac.uk 00006 // 00007 // dvi2bitmap 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 // dvi2bitmap 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 dvi2bitmap; if not, write to the Free Software 00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 // 00021 // The General Public License is distributed along with this 00022 // program in the file LICENCE. 00023 // 00024 // Author: Norman Gray <norman@astro.gla.ac.uk> 00025 // $Id: Bitmap.h,v 1.32 2003/10/03 13:17:41 norman Exp $ 00026 00027 00028 #ifndef BITMAP_HEADER_READ 00029 #define BITMAP_HEADER_READ 1 00030 00031 #include "Byte.h" 00032 #include "DviError.h" 00033 #include "verbosity.h" 00034 00035 class BitmapError : public DviError { 00036 public: 00037 BitmapError(string s) : DviError(s) { }; 00038 }; 00039 00040 class Bitmap { 00041 public: 00042 Bitmap (const int width, const int height, const int bpp=1, 00043 bool expandable=true, 00044 const int maxwidth=-1, const int maxheight=-1) 00045 throw (BitmapError); 00046 ~Bitmap(); 00047 00048 // make sure Left..Bottom are 0..3 (I should use an iterator, I know...) 00049 enum Margin { Left=0, Right=1, Top=2, Bottom=3, All}; 00050 00051 void paint (const int x, const int y, const int w, const int h, 00052 const Byte* b) 00053 throw (BitmapError); 00054 void rule (const int x, const int y, const int w, const int h) 00055 throw (BitmapError); 00056 void strut (const int x, const int y, 00057 const int l, const int r, 00058 const int t, const int b) 00059 throw (BitmapError); 00060 void write (const string filename, const string format) 00061 throw (BitmapError); 00062 void freeze (); 00063 void crop (); 00064 static void cropDefault (Margin spec, int pixels, bool absolute=false) 00065 throw (BitmapError); 00066 void crop (Margin spec, int pixels, bool absolute=false) 00067 throw (BitmapError); 00068 void blur (); 00069 void clear(); 00074 void setTransparent(const bool sw) { transparent_ = sw; } 00075 typedef struct BitmapColour_s { 00076 Byte red, green, blue; 00077 } BitmapColour; 00078 void setRGB (const bool fg, const BitmapColour*); 00079 static void setDefaultRGB (const bool fg, const BitmapColour*); 00080 void scaleDown (const int factor) 00081 throw (BitmapError); 00089 bool empty () const 00090 { return (bbL > W || bbR < 0 || bbT > H || bbB < 0); } 00091 bool overlaps() const; 00092 int* boundingBox(); 00098 int getWidth() const { return W; } 00104 int getHeight() const { return H; } 00110 static verbosities verbosity (const verbosities level) { 00111 enum verbosities oldv = verbosity_; 00112 verbosity_ = level; 00113 return oldv; 00114 } 00123 static void logBitmapInfo (const char *prefix) { 00124 logBitmapPrefix_ = prefix; 00125 }; 00126 00135 class BitmapMark { 00136 public: 00137 double x, y; 00138 }; 00139 void mark(const double x, const double y); 00140 BitmapMark* getMark(); 00141 00143 class const_iterator 00144 { 00145 public: 00146 Byte* operator*() throw (DviError); 00147 const_iterator& operator++() throw (DviError); 00148 bool operator==(const const_iterator& it) const; 00149 bool operator!=(const const_iterator& it) const; 00150 ~const_iterator(); 00151 private: 00152 const_iterator(); 00153 void init(Byte* b, int startx, int starty, int width, int nrows); 00154 Byte* b_; 00155 int rowLength_; 00156 int rowNumber_; 00157 int startColumn_; 00158 int lastRow_; 00159 friend class Bitmap; 00160 }; 00161 const_iterator runningIterator_; 00162 static const_iterator endIterator_; 00163 const_iterator begin(); 00164 const_iterator end() const; 00165 00166 private: 00167 void normalizeBB_(int& l, int& r, int& t, int& b); 00168 void usesBitmapArea_(const int ulx, const int uly, 00169 const int lrx, const int lry); 00171 Byte *B; 00173 int W, H; 00175 int maxW_, maxH_; 00177 bool isExpandable_; 00187 int bbL, bbR, bbT, bbB; 00189 int BB[4]; 00191 bool frozen_; 00193 int cropL, cropR, cropT, cropB; 00195 bool cropped_; 00197 BitmapMark* mark_; 00199 static int cropMarginDefault[4]; 00200 int cropMargin[4]; 00201 static bool cropMarginAbsDefault[4]; 00202 bool cropMarginAbs[4]; 00204 bool transparent_; 00205 BitmapColour fg_, bg_; 00207 bool customRGB_; 00209 static BitmapColour def_fg_, def_bg_; 00210 static bool def_customRGB_; 00212 int bpp_; 00214 Byte max_colour_; 00216 static verbosities verbosity_; 00218 static const char* logBitmapPrefix_; 00219 }; 00220 00221 #endif //#ifndef BITMAP_HEADER_READ

Generated on Sun Aug 21 18:21:02 2005 for dvi2bitmap by doxygen 1.3.8