24 #include <core/exception.h>
25 #include <fvutils/colormap/cmfile.h>
26 #include <fvutils/colormap/cmfile_yuvblock.h>
27 #include <fvutils/colormap/colormap.h>
28 #include <fvutils/colormap/yuvcm.h>
29 #include <sys/utsname.h>
33 namespace firevision {
45 for (iterator i = begin(); i != end(); ++i) {
68 header_->
depth = depth;
69 header_->
width = width;
107 "Colormap dimensions %dx%dx%d do not match expected dimensions %dx%dx%d",
116 printf(
"Adding colormap with dimensions %dx%dx%d\n",
122 for (std::list<ColormapFileBlock *>::iterator i =
blocks.begin(); i !=
blocks.end(); ++i) {
135 for (std::list<FireVisionDataFileBlock *>::iterator i = b.begin(); i != b.end(); ++i) {
136 if ((*i)->type() == CMFILE_TYPE_YUV) {
146 ColormapFile::assert_header()
150 throw fawkes::Exception(
"Cannot get header information, invalid ctor used or file not read?");
170 for (BlockList::iterator b = bl.begin(); b != bl.end(); ++b) {
171 if ((*b)->type() != CMFILE_TYPE_YUV) {
183 unsigned int level = 0;
184 for (BlockList::iterator b = bl.begin(); b != bl.end(); ++b) {
191 cm->
copy_uvplane((
unsigned char *)(*b)->data_ptr(), level++);
215 std::string rv = format;
217 struct utsname uname_info;
220 size_t loc = rv.find(
"%h");
221 while (loc != std::string::npos) {
222 rv.replace(loc, 2, uname_info.nodename);
243 return header_->
depth;
253 return header_->
width;
Base class for exceptions in Fawkes.
YUV block for colormap file.
Vector of colormap blocks.
~ColormapBlockVector()
Destructor.
static std::string compose_filename(const std::string format)
Compose filename.
uint16_t get_height()
Get height of colormap.
virtual void clear()
Clear internal storage.
uint16_t get_width()
Get width of colormap.
ColormapBlockVector * colormap_blocks()
Get colormap blocks.
Colormap * get_colormap()
Get a freshly generated colormap based on current file content.
void add_colormap(Colormap *colormap)
Add colormap.
static bool is_colormap_file(const char *filename)
Check if given file is a colormap file.
ColormapFile()
Constructor.
uint16_t get_depth()
Get depth of colormap.
virtual unsigned int depth() const =0
Get depth of colormap.
virtual unsigned int height() const =0
Get height of colormap.
virtual std::list< ColormapFileBlock * > get_blocks()=0
Get file blocks for this colormap.
virtual unsigned int width() const =0
Get width of colormap.
FireVision File Format for data files.
void * _spec_header
Content specific header.
virtual void clear()
Clear internal storage.
size_t _spec_header_size
Size in bytes of _spec_header.
virtual void add_block(FireVisionDataFileBlock *block)
Add a block.
std::list< FireVisionDataFileBlock * > BlockList
List of FireVision data file blocks.
static bool has_magic_token(const char *filename, unsigned short int magic_token)
Check if file has a certain magic token.
BlockList & blocks()
Get blocks.
void copy_uvplane(unsigned char *uvplane, unsigned int level)
Copy single U/V plane.
unsigned int plane_size() const
Get U/V plane size.