Go to the documentation of this file.00001
00002
00003
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef _CHOMP_BITMAPS_BITMAPS_H_
00043 #define _CHOMP_BITMAPS_BITMAPS_H_
00044
00045 #include "chomp/system/config.h"
00046 #include "chomp/system/textfile.h"
00047
00048 #include <iostream>
00049 #include <stdio.h>
00050 #include <cstdlib>
00051
00052 namespace chomp {
00053 namespace homology {
00054
00055
00056
00057 class bmpfile;
00058
00059
00060
00061
00062
00063
00067 class bmpfile
00068 {
00069 public:
00073 bmpfile (int _rows = 20);
00074
00076 ~bmpfile ();
00077
00078 #ifndef ReadOnly
00079 #define ReadOnly 0
00080 #endif
00081
00082 #ifndef ReadWrite
00083 #define ReadWrite 1
00084 #endif
00085
00086
00087
00088
00089
00090
00091 int open (const char *filename, int mode = ReadOnly,
00092 int quiet = 0);
00093
00103 int create (const char *filename, int _width, int _height,
00104 int _bitsperpixel = 24, int _pallength = 0,
00105 int32 *_pallette = NULL, int quiet = 0);
00106
00110 inline void invertedpicture (int _inverted = 1)
00111 {inverted = _inverted;};
00112
00115 int writeheader (void);
00116
00119 int32 getpixel (int x, int y, bool index = false);
00120
00122 int32 putpixel (int x, int y, long color = 0,
00123 bool index = false);
00124
00126 void drawpixel (int x, int y, int thickness = 1,
00127 long color = 0, bool index = false);
00128
00130 void drawsegment (int x1, int y1, int x2, int y2,
00131 int thickness = 1, long color = 0,
00132 bool index = false);
00133
00135 inline int picture_width (void) { return width; };
00136
00138 inline int picture_height (void) { return height; };
00139
00141 int32 x_resolution;
00142
00144 int32 y_resolution;
00145
00147 long rows_read;
00148
00150 long rows_written;
00151
00153 void flush (void);
00154
00156 int getbitsperpixel (void);
00157
00160 unsigned char *getrow (int row);
00161
00163 unsigned getrowlength () const;
00164
00166 inline int32 *getpalette (void) { return palette; };
00167
00169 inline int getpallength (void) { return pallength; };
00170
00171 private:
00173 char *header;
00174
00176 int pallength;
00177
00179 int32 *palette;
00180
00182 bool palette_allocated;
00183
00185 int *rownumber;
00186
00188 unsigned char **rowbuf;
00189
00191 char *changed;
00192
00194 unsigned char *defined;
00195
00197 int current;
00198
00200 int readrow (int row);
00201
00203 int writerow (int row);
00204
00206 int bmpstart;
00207
00209 unsigned rowlength;
00210
00212 int bitsperpixel;
00213
00215 int width;
00216
00218 int height;
00219
00221 FILE *fbmp;
00222
00225 int fileinuse;
00226
00232 int firstundefinedrow;
00233
00236 int firstundefinedbyte;
00237
00239 int rows;
00240
00242 unsigned char fillbyte;
00243
00248 int inverted;
00249
00250 };
00251
00252
00253 }
00254 }
00255
00256 #endif // _CHOMP_BITMAPS_BITMAPS_H_
00257
00259