cmfile.h
00001 00002 /************************************************************************** 00003 * cmfile.h - FVFF Colormap File Format 00004 * 00005 * Created: Sat Mar 29 12:49:48 2008 00006 * Copyright 2005-2008 Tim Niemueller [www.niemueller.de] 00007 * 00008 ***************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #ifndef __FIREVISION_FVUTILS_COLORMAP_CMFILE_H_ 00025 #define __FIREVISION_FVUTILS_COLORMAP_CMFILE_H_ 00026 00027 #include <fvutils/fileformat/fvfile.h> 00028 #include <fvutils/colormap/cmfile_block.h> 00029 #include <vector> 00030 #include <string> 00031 #include <stdint.h> 00032 00033 class Colormap; 00034 00035 #define CMFILE_MAGIC_TOKEN 0xFF01 00036 #define CMFILE_CUR_VERSION 2 00037 00038 #define CMFILE_TYPE_YUV 1 00039 00040 #pragma pack(push,4) 00041 /** Block header for a Colormap header block in a ColormapFile. */ 00042 typedef struct { 00043 uint16_t depth; /**< Y resolution */ 00044 uint16_t width; /**< U resolution */ 00045 uint16_t height; /**< V resolution */ 00046 uint16_t reserved; /**< reserved for future use, padding */ 00047 } cmfile_header_t; 00048 #pragma pack(pop) 00049 00050 class ColormapFile : public FireVisionDataFile 00051 { 00052 public: 00053 ColormapFile(); 00054 ColormapFile(uint16_t depth, uint16_t width, uint16_t height); 00055 00056 class ColormapBlockVector : public std::vector<ColormapFileBlock *> 00057 { 00058 public: 00059 ~ColormapBlockVector(); 00060 }; 00061 00062 void add_colormap(Colormap *colormap); 00063 ColormapBlockVector * colormap_blocks(); 00064 Colormap * get_colormap(); 00065 00066 uint16_t get_depth(); 00067 uint16_t get_width(); 00068 uint16_t get_height(); 00069 00070 static bool is_colormap_file(const char *filename); 00071 static std::string compose_filename(const std::string format); 00072 00073 virtual void clear(); 00074 00075 private: 00076 inline void assert_header(); 00077 private: 00078 cmfile_header_t *__header; 00079 }; 00080 00081 #endif

