Class to generate simple EPS files containing images and lines. More...
#include <mbl_eps_writer.h>
Public Member Functions | |
mbl_eps_writer () | |
Dflt ctor. | |
mbl_eps_writer (const char *path, double nx, double ny) | |
Open file and write header, given bounding box. | |
virtual | ~mbl_eps_writer () |
Destructor. | |
vcl_ofstream & | ofs () |
Current stream used to write EPS file. | |
void | set_grey_shade (double shade) |
Define shade of subsequent graphics [0,1] = black-white. | |
void | set_rgb (double r, double g, double b) |
Define colour of subsequent graphics r,g,b in [0,1]. | |
void | set_colour (const vcl_string &colour_name) |
Set colour of subsequent graphics using a named colour. | |
void | set_scaling (double s) |
Define scaling factor. | |
void | set_scaling (double sx, double sy) |
Define scaling factor. | |
bool | open (const char *path, double nx, double ny) |
Open file and write header, given bounding box. | |
bool | open (const char *path, const vil_image_view< vxl_byte > &image, double pixel_width_x, double pixel_width_y) |
Creates file and draws image, setting bounding box to that of image. | |
void | close () |
Write tail and close. | |
void | draw_disk (const vgl_point_2d< double > &p, double r) |
Draws disk of radius r around p, with current colour. | |
void | draw_circle (const vgl_point_2d< double > &p, double r) |
Draws circle of radius r around p, with current colour. | |
void | draw_line (const vgl_point_2d< double > &p1, const vgl_point_2d< double > &p2) |
Draws line segment from p1 to p2. | |
void | draw_polygon (const vcl_vector< vgl_point_2d< double > > &pts, bool closed=true, bool filled=false) |
Draws polygon connecting points. | |
void | set_line_width (double w) |
Define line width. | |
void | write_image_data (vcl_ostream &os, const vil_image_view< vxl_byte > &image) |
Writes first plane of image in hex format to os. | |
void | draw_image (const vil_image_view< vxl_byte > &image, double tx, double ty, double pixel_width_x, double pixel_width_y) |
Creates an image at (tx,ty) with given pixel widths. | |
Private Member Functions | |
void | draw_grey_image_block (const vil_image_view< vxl_byte > &image, double tx, double ty, double pixel_width_x, double pixel_width_y) |
Creates a greyscale image at (tx,ty) with given pixel widths. | |
void | draw_rgb_image_block (const vil_image_view< vxl_byte > &image, double tx, double ty, double pixel_width_x, double pixel_width_y) |
Creates a colour image with given pixel widths. | |
void | draw_image_block (const vil_image_view< vxl_byte > &image, double tx, double ty, double pixel_width_x, double pixel_width_y) |
Creates a grey or colour image with given pixel widths. | |
Private Attributes | |
vcl_ofstream | ofs_ |
Stream to eps file. | |
double | nx_ |
Bounding box (in points). | |
double | ny_ |
double | sx_ |
Current scaling. | |
double | sy_ |
Class to generate simple EPS files containing images and lines.
Note that Postscript uses units of points=1/72 inch. Scaling may be required. Also, by default origin is in bottom left. This class treats the origin at top right, to comply with usual VXL standards. The drawing area is a box (nx,ny), based at the origin.
The output eps file should be suitable for use in LaTeX documents.
Example usage:
mbl_eps_writer eps_writer("example.eps",100,100); eps_writer.set_colour("blue"); eps_writer.draw_circle(centre,radius); eps_writer.close();
Definition at line 32 of file mbl_eps_writer.h.
mbl_eps_writer::mbl_eps_writer | ( | ) |
Dflt ctor.
Definition at line 16 of file mbl_eps_writer.cxx.
mbl_eps_writer::mbl_eps_writer | ( | const char * | path, |
double | nx, | ||
double | ny | ||
) |
Open file and write header, given bounding box.
Bounding box specified in "points" (72 points=1 inch)
Definition at line 23 of file mbl_eps_writer.cxx.
mbl_eps_writer::~mbl_eps_writer | ( | ) | [virtual] |
Destructor.
Definition at line 33 of file mbl_eps_writer.cxx.
void mbl_eps_writer::close | ( | ) |
Write tail and close.
Definition at line 122 of file mbl_eps_writer.cxx.
void mbl_eps_writer::draw_circle | ( | const vgl_point_2d< double > & | p, |
double | r | ||
) |
Draws circle of radius r around p, with current colour.
Draws circle of radius r around p.
Definition at line 136 of file mbl_eps_writer.cxx.
void mbl_eps_writer::draw_disk | ( | const vgl_point_2d< double > & | p, |
double | r | ||
) |
Draws disk of radius r around p, with current colour.
Draws disk of radius r around p.
Definition at line 144 of file mbl_eps_writer.cxx.
void mbl_eps_writer::draw_grey_image_block | ( | const vil_image_view< vxl_byte > & | image, |
double | tx, | ||
double | ty, | ||
double | pixel_width_x, | ||
double | pixel_width_y | ||
) | [private] |
Creates a greyscale image at (tx,ty) with given pixel widths.
Size in points given by sx(),sy() * given values. Image must be no bigger than 255x255. Some postscript can't cope with bigger blocks.
Size in points given by sx(),sy() * given values. Image must be no bigger than 255x255 Some postscript can't cope with bigger blocks.
Definition at line 231 of file mbl_eps_writer.cxx.
void mbl_eps_writer::draw_image | ( | const vil_image_view< vxl_byte > & | image, |
double | tx, | ||
double | ty, | ||
double | pixel_width_x, | ||
double | pixel_width_y | ||
) |
Creates an image at (tx,ty) with given pixel widths.
Size in points given by sx(),sy() * given values.
Definition at line 199 of file mbl_eps_writer.cxx.
void mbl_eps_writer::draw_image_block | ( | const vil_image_view< vxl_byte > & | image, |
double | tx, | ||
double | ty, | ||
double | pixel_width_x, | ||
double | pixel_width_y | ||
) | [private] |
Creates a grey or colour image with given pixel widths.
Creates an image at (tx,ty) with given pixel widths.
Image assumed to have either 1 or 3 planes. Image must be no bigger than 255x255. Some postscript can't cope with bigger blocks.
Size in points given by sx(),sy() * given values.
Definition at line 280 of file mbl_eps_writer.cxx.
void mbl_eps_writer::draw_line | ( | const vgl_point_2d< double > & | p1, |
const vgl_point_2d< double > & | p2 | ||
) |
Draws line segment from p1 to p2.
Definition at line 152 of file mbl_eps_writer.cxx.
void mbl_eps_writer::draw_polygon | ( | const vcl_vector< vgl_point_2d< double > > & | pts, |
bool | closed = true , |
||
bool | filled = false |
||
) |
Draws polygon connecting points.
If closed, then adds line joining last to first point. If filled, then fills with current colour/greyshade.
Definition at line 163 of file mbl_eps_writer.cxx.
void mbl_eps_writer::draw_rgb_image_block | ( | const vil_image_view< vxl_byte > & | image, |
double | tx, | ||
double | ty, | ||
double | pixel_width_x, | ||
double | pixel_width_y | ||
) | [private] |
Creates a colour image with given pixel widths.
Image assumed to be a 3 plane image. Image must be no bigger than 255x255. Some postscript can't cope with bigger blocks.
Image assumed to be a 3 plane image.
Definition at line 254 of file mbl_eps_writer.cxx.
vcl_ofstream& mbl_eps_writer::ofs | ( | ) | [inline] |
Current stream used to write EPS file.
Definition at line 82 of file mbl_eps_writer.h.
bool mbl_eps_writer::open | ( | const char * | path, |
double | nx, | ||
double | ny | ||
) |
Open file and write header, given bounding box.
Open file and write header.
Bounding box specified in "points" (72 points=1 inch)
Definition at line 84 of file mbl_eps_writer.cxx.
bool mbl_eps_writer::open | ( | const char * | path, |
const vil_image_view< vxl_byte > & | image, | ||
double | pixel_width_x, | ||
double | pixel_width_y | ||
) |
Creates file and draws image, setting bounding box to that of image.
Sets scaling to pixel widths, so that subsequent points are interpreted in pixel units.
Definition at line 108 of file mbl_eps_writer.cxx.
void mbl_eps_writer::set_colour | ( | const vcl_string & | colour_name | ) |
Set colour of subsequent graphics using a named colour.
Valid options include black,white,grey,red,green,blue, cyan,yellow. Note: Probably need a tidy map thing to do this properly. Sets to grey if colour not known.
Definition at line 55 of file mbl_eps_writer.cxx.
void mbl_eps_writer::set_grey_shade | ( | double | shade | ) |
Define shade of subsequent graphics [0,1] = black-white.
Define shade of subsequent lines [0,1] = black-white.
Definition at line 38 of file mbl_eps_writer.cxx.
void mbl_eps_writer::set_line_width | ( | double | w | ) |
Define line width.
Definition at line 129 of file mbl_eps_writer.cxx.
void mbl_eps_writer::set_rgb | ( | double | r, |
double | g, | ||
double | b | ||
) |
Define colour of subsequent graphics r,g,b in [0,1].
Define colour of subsequent lines r,g,b in [0,1].
Definition at line 46 of file mbl_eps_writer.cxx.
void mbl_eps_writer::set_scaling | ( | double | s | ) |
Define scaling factor.
Definition at line 71 of file mbl_eps_writer.cxx.
void mbl_eps_writer::set_scaling | ( | double | sx, |
double | sy | ||
) |
Define scaling factor.
Definition at line 77 of file mbl_eps_writer.cxx.
void mbl_eps_writer::write_image_data | ( | vcl_ostream & | os, |
const vil_image_view< vxl_byte > & | image | ||
) |
Writes first plane of image in hex format to os.
Definition at line 181 of file mbl_eps_writer.cxx.
double mbl_eps_writer::nx_ [private] |
Bounding box (in points).
Definition at line 39 of file mbl_eps_writer.h.
double mbl_eps_writer::ny_ [private] |
Definition at line 39 of file mbl_eps_writer.h.
vcl_ofstream mbl_eps_writer::ofs_ [private] |
Stream to eps file.
Definition at line 36 of file mbl_eps_writer.h.
double mbl_eps_writer::sx_ [private] |
Current scaling.
Definition at line 42 of file mbl_eps_writer.h.
double mbl_eps_writer::sy_ [private] |
Definition at line 42 of file mbl_eps_writer.h.