1//---------------------------------------------------------------------------- 2// Anti-Grain Geometry - Version 2.2 3// Copyright (C) 2002-2004 Maxim Shemanarev (http://www.antigrain.com) 4// 5// Permission to copy, use, modify, sell and distribute this software 6// is granted provided this copyright notice appears in all copies. 7// This software is provided "as is" without express or implied 8// warranty, and with no claim as to its suitability for any purpose. 9// 10//---------------------------------------------------------------------------- 11// Contact: mcseem@antigrain.com 12// mcseemagg@yahoo.com 13// http://www.antigrain.com 14//---------------------------------------------------------------------------- 15// 16// Conversion from one colorspace/pixel format to another 17// 18//---------------------------------------------------------------------------- 19 20#ifndef AGG_COLOR_CONV_INCLUDED 21#define AGG_COLOR_CONV_INCLUDED 22 23#include <string.h> 24#include "agg_basics.h" 25#include "agg_rendering_buffer.h" 26 27 28 29 30namespace agg 31{ 32 33 //--------------------------------------------------------------color_conv 34 template<class CopyRow> 35 void color_conv(rendering_buffer* dst, 36 const rendering_buffer* src, 37 CopyRow copy_row_functor) 38 { 39 unsigned width = src->width(); 40 unsigned height = src->height(); 41 42 if(dst->width() < width) width = dst->width(); 43 if(dst->height() < height) height = dst->height(); 44 45 if(width) 46 { 47 unsigned y; 48 for(y = 0; y < height; y++) 49 { 50 copy_row_functor(dst->row(y), src->row(y), width); 51 } 52 } 53 } 54 55 56 //---------------------------------------------------------color_conv_row 57 template<class CopyRow> 58 void color_conv_row(unsigned char* dst, 59 const unsigned char* src, 60 unsigned width, 61 CopyRow copy_row_functor) 62 { 63 copy_row_functor(dst, src, width); 64 } 65 66 67 //---------------------------------------------------------color_conv_same 68 template<int BPP> class color_conv_same 69 { 70 public: 71 void operator () (unsigned char* dst, 72 const unsigned char* src, 73 unsigned width) const 74 { 75 memmove(dst, src, width*BPP); 76 } 77 }; 78 79 80} 81 82 83 84#endif 85