Fawkes API
Fawkes Development Version
|
00001 00002 /************************************************************************** 00003 * yuvcm.h - YUV colormap 00004 * 00005 * Created: Sat Mar 29 12:45:29 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_YUVCM_H_ 00025 #define __FIREVISION_FVUTILS_COLORMAP_YUVCM_H_ 00026 00027 #include <fvutils/colormap/colormap.h> 00028 00029 #include <sys/types.h> 00030 #include <fvutils/base/types.h> 00031 00032 namespace firevision { 00033 #if 0 /* just to make Emacs auto-indent happy */ 00034 } 00035 #endif 00036 00037 class SharedMemoryLookupTable; 00038 00039 class YuvColormap : public Colormap 00040 { 00041 public: 00042 YuvColormap(unsigned int depth = 1, unsigned int width = 256, unsigned int height = 256); 00043 YuvColormap(const char *shmem_lut_id, unsigned int depth = 1, unsigned int width = 256, unsigned int height = 256); 00044 YuvColormap(const char *shmem_lut_id, bool destroy_on_free, unsigned int depth = 1, unsigned int width = 256, unsigned int height = 256); 00045 YuvColormap(YuvColormap *cm, const char *shmem_lut_id, bool destroy_on_free = false); 00046 virtual ~YuvColormap(); 00047 00048 virtual color_t determine(unsigned int y, unsigned int u, unsigned int v) const; 00049 virtual void set(unsigned int y, unsigned int u, unsigned int v, color_t c); 00050 00051 virtual void reset(); 00052 virtual void set(unsigned char *buffer); 00053 00054 virtual size_t size(); 00055 00056 virtual unsigned char * get_buffer() const; 00057 00058 virtual Colormap & operator+=(const Colormap & cmlt); 00059 virtual Colormap & operator+=(const char *filename); 00060 virtual Colormap & operator=(const YuvColormap &yuvcm); 00061 00062 virtual unsigned int width() const; 00063 virtual unsigned int height() const; 00064 virtual unsigned int depth() const; 00065 virtual unsigned int deepness() const; 00066 unsigned int plane_size() const; 00067 00068 virtual std::list<ColormapFileBlock *> get_blocks(); 00069 00070 void copy_uvplane(unsigned char *uvplane, unsigned int level); 00071 00072 void replace_color(color_t from, color_t to); 00073 00074 private: 00075 void constructor(unsigned int depth, unsigned int width, unsigned int height, 00076 const char *shmem_lut_id = 0, bool destroy_on_free = false); 00077 00078 00079 SharedMemoryLookupTable *__shm_lut; 00080 unsigned char *__lut; 00081 size_t __lut_size; 00082 00083 unsigned int __width; 00084 unsigned int __height; 00085 unsigned int __depth; 00086 unsigned int __depth_div; 00087 unsigned int __width_div; 00088 unsigned int __height_div; 00089 unsigned int __plane_size; 00090 }; 00091 00092 00093 inline color_t 00094 YuvColormap::determine(unsigned int y, unsigned int u, unsigned int v) const 00095 { 00096 return (color_t) *(__lut + (y / __depth_div) * __plane_size + (v / __height_div) * __width + (u / __width_div)); 00097 } 00098 00099 } // end namespace firevision 00100 00101 #endif