Fawkes API  Fawkes Development Version
pnm.h
1 
2 /***************************************************************************
3  * pnm.h - Header for tool to write PNM,
4  * for more information on the different available image formats see the
5  * NetPBM documentation.
6  *
7  * Generated: Mon Feb 06 19:18:03 2006
8  * Copyright 2005-2007 Tim Niemueller [www.niemueller.de]
9  *
10  ****************************************************************************/
11 
12 /* This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version. A runtime exception applies to
16  * this software (see LICENSE.GPL_WRE file mentioned below for details).
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU Library General Public License for more details.
22  *
23  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
24  */
25 
26 #ifndef __FIREVISION_FVUTILS_WRITERS_PNM_H_
27 #define __FIREVISION_FVUTILS_WRITERS_PNM_H_
28 
29 
30 #include <fvutils/color/colorspaces.h>
31 #include <fvutils/writers/writer.h>
32 
33 namespace firevision {
34 #if 0 /* just to make Emacs auto-indent happy */
35 }
36 #endif
37 
38 /** PNM subtype. */
39 typedef enum {
40  PNM_PBM, /**< PBM, B/W */
41  PNM_PBM_ASCII, /**< PBM, B/W, ASCII */
42  PNM_PGM, /**< PGM, grey */
43  PNM_PGM_ASCII, /**< PGM, grey, ASCII */
44  PNM_PPM, /**< PPM, color */
45  PNM_PPM_ASCII /**< PPM, color, ASCII */
46 } PNMFormat;
47 
48 
49 class PNMWriter : public Writer
50 {
51  public:
52  PNMWriter(PNMFormat format);
53  PNMWriter(PNMFormat format, const char *filename, unsigned int width, unsigned int height);
54 
55  virtual void set_buffer(colorspace_t cspace, unsigned char *buffer);
56  virtual void write();
57 
58  private:
59 
60  unsigned int calc_buffer_size();
61 
62  unsigned int write_header(bool simulate = false);
63  const char * format2string(PNMFormat format);
64 
65  PNMFormat format;
66  unsigned int buffer_size;
67  unsigned char *buffer;
68  unsigned char *buffer_start;
69  unsigned int width;
70  unsigned int height;
71 };
72 
73 } // end namespace firevision
74 
75 #endif
colorspace_t cspace
The colorspace of the image.
Definition: writer.h:55
Interface to write images.
Definition: writer.h:34
virtual void write()
Write to file.
Definition: pnm.cpp:228
PNMWriter(PNMFormat format)
Constructor.
Definition: pnm.cpp:46
virtual void set_buffer(colorspace_t cspace, unsigned char *buffer)
Set image buffer.
Definition: pnm.cpp:78
PNM file writer.
Definition: pnm.h:49
char * filename
The complete filename.
Definition: writer.h:48