cmfile_yuvblock.cpp

00001 
00002 /**************************************************************************
00003  *  cmfile_yuvblock.cpp - FVFF Colormap File YUV Block
00004  *
00005  *  Created: Mon Mar 31 18:10:01 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 #include <fvutils/colormap/cmfile_yuvblock.h>
00025 #include <fvutils/colormap/cmfile.h>
00026 #include <fvutils/colormap/yuvcm.h>
00027 
00028 #include <core/exceptions/software.h>
00029 #include <cstring>
00030 
00031 namespace firevision {
00032 #if 0 /* just to make Emacs auto-indent happy */
00033 }
00034 #endif
00035 
00036 /** @class ColormapFileYuvBlock <fvutils/colormap/cmfile_yuvblock.h>
00037  * YUV block for colormap file.
00038  * @author Tim Niemueller
00039  */
00040 
00041 /** Constructor.
00042  * @param cm YUV colormap that this block shall represent.
00043  * @param level Y level
00044  */
00045 ColormapFileYuvBlock::ColormapFileYuvBlock(YuvColormap *cm, unsigned int level)
00046   : ColormapFileBlock(CMFILE_TYPE_YUV, cm->plane_size(), sizeof(cmfile_yuvblock_header_t))
00047 {
00048   if ( level > cm->depth() ) {
00049     throw fawkes::OutOfBoundsException("YuvColormap level is out of bounds", level, 0, cm->depth());
00050   }
00051 
00052   __cm    = cm;
00053   __level = level;
00054 
00055   __header = (cmfile_yuvblock_header_t *)_spec_header;
00056   __header->range_from = level * cm->deepness() / cm->depth();
00057   __header->range_to   = ((level + 1) * cm->deepness() / cm->depth()) - 1;
00058 
00059   memcpy(_data, __cm->get_buffer() + level * cm->plane_size(), _data_size);
00060 }
00061 
00062 
00063 /** Copy Constructor.
00064  * It is assumed that the block actually is a rectification LUT info block. Check that
00065  * before calling this method.
00066  * @param block block to copy
00067  */
00068 ColormapFileYuvBlock::ColormapFileYuvBlock(FireVisionDataFileBlock *block)
00069   : ColormapFileBlock(block)
00070 {
00071   __header = (cmfile_yuvblock_header_t *)_spec_header;
00072 }
00073 
00074 
00075 /** Range from value.
00076  * @return range from value
00077  */
00078 unsigned int
00079 ColormapFileYuvBlock::range_from() const
00080 {
00081   return __header->range_from;
00082 }
00083 
00084 
00085 /** Range to value.
00086  * @return range to value
00087  */
00088 unsigned int
00089 ColormapFileYuvBlock::range_to() const
00090 {
00091   return __header->range_to;
00092 }
00093 
00094 } // end namespace firevision

Generated on Tue Feb 22 13:31:16 2011 for Fawkes API by  doxygen 1.4.7