Bitmap.h
Go to the documentation of this file.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
#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
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
Generated on Sun Aug 21 18:21:02 2005 for dvi2bitmap by
1.3.8