pnm.h

00001
00002 /***************************************************************************
00003  *  pnm.h - Header for tool to write PNM,
00004  *  for more information on the different available image formats see the
00005  *  NetPBM documentation.
00006  *
00007  *  Generated: Mon Feb 06 19:18:03 2006
00008  *  Copyright  2005-2007  Tim Niemueller [www.niemueller.de]
00009  *
00010  ****************************************************************************/
00011
00012 /*  This program is free software; you can redistribute it and/or modify
00013  *  it under the terms of the GNU General Public License as published by
00014  *  the Free Software Foundation; either version 2 of the License, or
00015  *  (at your option) any later version. A runtime exception applies to
00016  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00017  *
00018  *  This program is distributed in the hope that it will be useful,
00019  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  *  GNU Library General Public License for more details.
00022  *
00023  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00024  */
00025
00026 #ifndef __FIREVISION_FVUTILS_WRITERS_PNM_H_
00027 #define __FIREVISION_FVUTILS_WRITERS_PNM_H_
00028 
00029
00030 #include <fvutils/color/colorspaces.h>
00031 #include <fvutils/writers/writer.h>
00032 
00033 /** PNm subtype. */
00034 typedef enum {
00035   PNM_PBM,              /**< PBM, B/W */
00036   PNM_PBM_ASCII,        /**< PBM, B/W, ASCII */
00037   PNM_PGM,              /**< PGM, grey */
00038   PNM_PGM_ASCII,        /**< PGM, grey, ASCII */
00039   PNM_PPM,              /**< PPM, color */
00040   PNM_PPM_ASCII         /**< PPM, color, ASCII */
00041 } PNMFormat;
00042
00043
00044 class PNMWriter : public Writer
00045 {
00046  public:
00047   PNMWriter(PNMFormat format);
00048   PNMWriter(PNMFormat format, const char *filename, unsigned int width, unsigned int height);
00049
00050   virtual void set_buffer(colorspace_t cspace, unsigned char *buffer);
00051   virtual void write();
00052
00053  private:
00054
00055   unsigned int calc_buffer_size();
00056
00057   unsigned int write_header(bool simulate = false);
00058   const char * format2string(PNMFormat format);
00059
00060   PNMFormat      format;
00061   unsigned int   buffer_size;
00062   unsigned char *buffer;
00063   unsigned char *buffer_start;
00064   unsigned int   width;
00065   unsigned int   height;
00066 };
00067
00068
00069
00070 #endif