Fawkes API  Fawkes Development Version
cmfile.h
1 
2 /**************************************************************************
3  * cmfile.h - FVFF Colormap File Format
4  *
5  * Created: Sat Mar 29 12:49:48 2008
6  * Copyright 2005-2008 Tim Niemueller [www.niemueller.de]
7  *
8  ***************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef _FIREVISION_FVUTILS_COLORMAP_CMFILE_H_
25 #define _FIREVISION_FVUTILS_COLORMAP_CMFILE_H_
26 
27 #include <fvutils/colormap/cmfile_block.h>
28 #include <fvutils/fileformat/fvfile.h>
29 
30 #include <stdint.h>
31 #include <string>
32 #include <vector>
33 
34 namespace firevision {
35 
36 class Colormap;
37 
38 #define CMFILE_MAGIC_TOKEN 0xFF01
39 #define CMFILE_CUR_VERSION 2
40 
41 #define CMFILE_TYPE_YUV 1
42 
43 #pragma pack(push, 4)
44 /** Block header for a Colormap header block in a ColormapFile. */
45 typedef struct
46 {
47  uint16_t depth; /**< Y resolution */
48  uint16_t width; /**< U resolution */
49  uint16_t height; /**< V resolution */
50  uint16_t reserved; /**< reserved for future use, padding */
52 #pragma pack(pop)
53 
55 {
56 public:
57  ColormapFile();
58  ColormapFile(uint16_t depth, uint16_t width, uint16_t height);
59 
60  class ColormapBlockVector : public std::vector<ColormapFileBlock *>
61  {
62  public:
64  };
65 
66  void add_colormap(Colormap *colormap);
69 
70  uint16_t get_depth();
71  uint16_t get_width();
72  uint16_t get_height();
73 
74  static bool is_colormap_file(const char *filename);
75  static std::string compose_filename(const std::string format);
76 
77  virtual void clear();
78 
79 private:
80  inline void assert_header();
81 
82 private:
83  cmfile_header_t *header_;
84 };
85 
86 } // end namespace firevision
87 
88 #endif
Vector of colormap blocks.
Definition: cmfile.h:61
Colormap file.
Definition: cmfile.h:55
static std::string compose_filename(const std::string format)
Compose filename.
Definition: cmfile.cpp:213
uint16_t get_height()
Get height of colormap.
Definition: cmfile.cpp:260
virtual void clear()
Clear internal storage.
Definition: cmfile.cpp:230
uint16_t get_width()
Get width of colormap.
Definition: cmfile.cpp:250
ColormapBlockVector * colormap_blocks()
Get colormap blocks.
Definition: cmfile.cpp:131
Colormap * get_colormap()
Get a freshly generated colormap based on current file content.
Definition: cmfile.cpp:164
void add_colormap(Colormap *colormap)
Add colormap.
Definition: cmfile.cpp:89
static bool is_colormap_file(const char *filename)
Check if given file is a colormap file.
Definition: cmfile.cpp:202
ColormapFile()
Constructor.
Definition: cmfile.cpp:76
uint16_t get_depth()
Get depth of colormap.
Definition: cmfile.cpp:240
Colormap interface.
Definition: colormap.h:37
FireVision File Format for data files.
Definition: fvfile.h:36
Block header for a Colormap header block in a ColormapFile.
Definition: cmfile.h:46
uint16_t width
U resolution.
Definition: cmfile.h:48
uint16_t depth
Y resolution.
Definition: cmfile.h:47
uint16_t height
V resolution.
Definition: cmfile.h:49
uint16_t reserved
reserved for future use, padding
Definition: cmfile.h:50