Repo created
This commit is contained in:
parent
4af19165ec
commit
68073add76
12458 changed files with 12350765 additions and 2 deletions
128
3party/agg/util/agg_color_conv.h
Normal file
128
3party/agg/util/agg_color_conv.h
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
//----------------------------------------------------------------------------
|
||||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// Contact: mcseem@antigrain.com
|
||||
// mcseemagg@yahoo.com
|
||||
// http://www.antigrain.com
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Conversion from one colorspace/pixel format to another
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifndef AGG_COLOR_CONV_INCLUDED
|
||||
#define AGG_COLOR_CONV_INCLUDED
|
||||
|
||||
#include <string.h>
|
||||
#include "agg_basics.h"
|
||||
#include "agg_rendering_buffer.h"
|
||||
|
||||
|
||||
|
||||
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//--------------------------------------------------------------color_conv
|
||||
template<class RenBuf, class CopyRow>
|
||||
void color_conv(RenBuf* dst, const RenBuf* src, CopyRow copy_row_functor)
|
||||
{
|
||||
unsigned width = src->width();
|
||||
unsigned height = src->height();
|
||||
|
||||
if(dst->width() < width) width = dst->width();
|
||||
if(dst->height() < height) height = dst->height();
|
||||
|
||||
if(width)
|
||||
{
|
||||
unsigned y;
|
||||
for(y = 0; y < height; y++)
|
||||
{
|
||||
copy_row_functor(dst->row_ptr(0, y, width),
|
||||
src->row_ptr(y),
|
||||
width);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------color_conv_row
|
||||
template<class CopyRow>
|
||||
void color_conv_row(int8u* dst,
|
||||
const int8u* src,
|
||||
unsigned width,
|
||||
CopyRow copy_row_functor)
|
||||
{
|
||||
copy_row_functor(dst, src, width);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------color_conv_same
|
||||
template<int BPP> class color_conv_same
|
||||
{
|
||||
public:
|
||||
void operator () (int8u* dst,
|
||||
const int8u* src,
|
||||
unsigned width) const
|
||||
{
|
||||
memmove(dst, src, width*BPP);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Generic pixel converter.
|
||||
template<class DstFormat, class SrcFormat>
|
||||
struct conv_pixel
|
||||
{
|
||||
void operator()(void* dst, const void* src) const
|
||||
{
|
||||
// Read a pixel from the source format and write it to the destination format.
|
||||
DstFormat::write_plain_color(dst, SrcFormat::read_plain_color(src));
|
||||
}
|
||||
};
|
||||
|
||||
// Generic row converter. Uses conv_pixel to convert individual pixels.
|
||||
template<class DstFormat, class SrcFormat>
|
||||
struct conv_row
|
||||
{
|
||||
void operator()(void* dst, const void* src, unsigned width) const
|
||||
{
|
||||
conv_pixel<DstFormat, SrcFormat> conv;
|
||||
do
|
||||
{
|
||||
conv(dst, src);
|
||||
dst = (int8u*)dst + DstFormat::pix_width;
|
||||
src = (int8u*)src + SrcFormat::pix_width;
|
||||
}
|
||||
while (--width);
|
||||
}
|
||||
};
|
||||
|
||||
// Specialization for case where source and destination formats are identical.
|
||||
template<class Format>
|
||||
struct conv_row<Format, Format>
|
||||
{
|
||||
void operator()(void* dst, const void* src, unsigned width) const
|
||||
{
|
||||
memmove(dst, src, width * Format::pix_width);
|
||||
}
|
||||
};
|
||||
|
||||
// Top-level conversion function, converts one pixel format to any other.
|
||||
template<class DstFormat, class SrcFormat, class RenBuf>
|
||||
void convert(RenBuf* dst, const RenBuf* src)
|
||||
{
|
||||
color_conv(dst, src, conv_row<DstFormat, SrcFormat>());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
285
3party/agg/util/agg_color_conv_rgb16.h
Normal file
285
3party/agg/util/agg_color_conv_rgb16.h
Normal file
|
|
@ -0,0 +1,285 @@
|
|||
//----------------------------------------------------------------------------
|
||||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// Contact: mcseem@antigrain.com
|
||||
// mcseemagg@yahoo.com
|
||||
// http://www.antigrain.com
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// This part of the library has been sponsored by
|
||||
// Liberty Technology Systems, Inc., visit http://lib-sys.com
|
||||
//
|
||||
// Liberty Technology Systems, Inc. is the provider of
|
||||
// PostScript and PDF technology for software developers.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// A set of functors used with color_conv(). See file agg_color_conv.h
|
||||
// These functors can convert images with up to 8 bits per component.
|
||||
// Use convertors in the following way:
|
||||
//
|
||||
// agg::color_conv(dst, src, agg::color_conv_XXXX_to_YYYY());
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifndef AGG_COLOR_CONV_RGB16_INCLUDED
|
||||
#define AGG_COLOR_CONV_RGB16_INCLUDED
|
||||
|
||||
#include "agg_basics.h"
|
||||
#include "agg_color_conv.h"
|
||||
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//-------------------------------------------------color_conv_gray16_to_gray8
|
||||
class color_conv_gray16_to_gray8
|
||||
{
|
||||
public:
|
||||
void operator () (int8u* dst,
|
||||
const int8u* src,
|
||||
unsigned width) const
|
||||
{
|
||||
int16u* s = (int16u*)src;
|
||||
do
|
||||
{
|
||||
*dst++ = *s++ >> 8;
|
||||
}
|
||||
while(--width);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------color_conv_rgb24_rgb48
|
||||
template<int I1, int I3> class color_conv_rgb24_rgb48
|
||||
{
|
||||
public:
|
||||
void operator () (int8u* dst,
|
||||
const int8u* src,
|
||||
unsigned width) const
|
||||
{
|
||||
int16u* d = (int16u*)dst;
|
||||
do
|
||||
{
|
||||
*d++ = (src[I1] << 8) | src[I1];
|
||||
*d++ = (src[1] << 8) | src[1] ;
|
||||
*d++ = (src[I3] << 8) | src[I3];
|
||||
src += 3;
|
||||
}
|
||||
while(--width);
|
||||
}
|
||||
};
|
||||
|
||||
typedef color_conv_rgb24_rgb48<0,2> color_conv_rgb24_to_rgb48;
|
||||
typedef color_conv_rgb24_rgb48<0,2> color_conv_bgr24_to_bgr48;
|
||||
typedef color_conv_rgb24_rgb48<2,0> color_conv_rgb24_to_bgr48;
|
||||
typedef color_conv_rgb24_rgb48<2,0> color_conv_bgr24_to_rgb48;
|
||||
|
||||
|
||||
//-----------------------------------------------------color_conv_rgb24_rgb48
|
||||
template<int I1, int I3> class color_conv_rgb48_rgb24
|
||||
{
|
||||
public:
|
||||
void operator () (int8u* dst,
|
||||
const int8u* src,
|
||||
unsigned width) const
|
||||
{
|
||||
const int16u* s = (const int16u*)src;
|
||||
do
|
||||
{
|
||||
*dst++ = s[I1] >> 8;
|
||||
*dst++ = s[1] >> 8;
|
||||
*dst++ = s[I3] >> 8;
|
||||
s += 3;
|
||||
}
|
||||
while(--width);
|
||||
}
|
||||
};
|
||||
|
||||
typedef color_conv_rgb48_rgb24<0,2> color_conv_rgb48_to_rgb24;
|
||||
typedef color_conv_rgb48_rgb24<0,2> color_conv_bgr48_to_bgr24;
|
||||
typedef color_conv_rgb48_rgb24<2,0> color_conv_rgb48_to_bgr24;
|
||||
typedef color_conv_rgb48_rgb24<2,0> color_conv_bgr48_to_rgb24;
|
||||
|
||||
|
||||
//----------------------------------------------color_conv_rgbAAA_rgb24
|
||||
template<int R, int B> class color_conv_rgbAAA_rgb24
|
||||
{
|
||||
public:
|
||||
void operator () (int8u* dst,
|
||||
const int8u* src,
|
||||
unsigned width) const
|
||||
{
|
||||
do
|
||||
{
|
||||
int32u rgb = *(int32u*)src;
|
||||
dst[R] = int8u(rgb >> 22);
|
||||
dst[1] = int8u(rgb >> 12);
|
||||
dst[B] = int8u(rgb >> 2);
|
||||
src += 4;
|
||||
dst += 3;
|
||||
}
|
||||
while(--width);
|
||||
}
|
||||
};
|
||||
|
||||
typedef color_conv_rgbAAA_rgb24<0,2> color_conv_rgbAAA_to_rgb24;
|
||||
typedef color_conv_rgbAAA_rgb24<2,0> color_conv_rgbAAA_to_bgr24;
|
||||
typedef color_conv_rgbAAA_rgb24<2,0> color_conv_bgrAAA_to_rgb24;
|
||||
typedef color_conv_rgbAAA_rgb24<0,2> color_conv_bgrAAA_to_bgr24;
|
||||
|
||||
|
||||
//----------------------------------------------color_conv_rgbBBA_rgb24
|
||||
template<int R, int B> class color_conv_rgbBBA_rgb24
|
||||
{
|
||||
public:
|
||||
void operator () (int8u* dst,
|
||||
const int8u* src,
|
||||
unsigned width) const
|
||||
{
|
||||
do
|
||||
{
|
||||
int32u rgb = *(int32u*)src;
|
||||
dst[R] = int8u(rgb >> 24);
|
||||
dst[1] = int8u(rgb >> 13);
|
||||
dst[B] = int8u(rgb >> 2);
|
||||
src += 4;
|
||||
dst += 3;
|
||||
}
|
||||
while(--width);
|
||||
}
|
||||
};
|
||||
|
||||
typedef color_conv_rgbBBA_rgb24<0,2> color_conv_rgbBBA_to_rgb24;
|
||||
typedef color_conv_rgbBBA_rgb24<2,0> color_conv_rgbBBA_to_bgr24;
|
||||
|
||||
|
||||
//----------------------------------------------color_conv_bgrABB_rgb24
|
||||
template<int B, int R> class color_conv_bgrABB_rgb24
|
||||
{
|
||||
public:
|
||||
void operator () (int8u* dst,
|
||||
const int8u* src,
|
||||
unsigned width) const
|
||||
{
|
||||
do
|
||||
{
|
||||
int32u bgr = *(int32u*)src;
|
||||
dst[R] = int8u(bgr >> 3);
|
||||
dst[1] = int8u(bgr >> 14);
|
||||
dst[B] = int8u(bgr >> 24);
|
||||
src += 4;
|
||||
dst += 3;
|
||||
}
|
||||
while(--width);
|
||||
}
|
||||
};
|
||||
|
||||
typedef color_conv_bgrABB_rgb24<2,0> color_conv_bgrABB_to_rgb24;
|
||||
typedef color_conv_bgrABB_rgb24<0,2> color_conv_bgrABB_to_bgr24;
|
||||
|
||||
|
||||
//-------------------------------------------------color_conv_rgba64_rgba32
|
||||
template<int I1, int I2, int I3, int I4> class color_conv_rgba64_rgba32
|
||||
{
|
||||
public:
|
||||
void operator () (int8u* dst,
|
||||
const int8u* src,
|
||||
unsigned width) const
|
||||
{
|
||||
do
|
||||
{
|
||||
*dst++ = int8u(((int16u*)src)[I1] >> 8);
|
||||
*dst++ = int8u(((int16u*)src)[I2] >> 8);
|
||||
*dst++ = int8u(((int16u*)src)[I3] >> 8);
|
||||
*dst++ = int8u(((int16u*)src)[I4] >> 8);
|
||||
src += 8;
|
||||
}
|
||||
while(--width);
|
||||
}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
typedef color_conv_rgba64_rgba32<0,1,2,3> color_conv_rgba64_to_rgba32; //----color_conv_rgba64_to_rgba32
|
||||
typedef color_conv_rgba64_rgba32<0,1,2,3> color_conv_argb64_to_argb32; //----color_conv_argb64_to_argb32
|
||||
typedef color_conv_rgba64_rgba32<0,1,2,3> color_conv_bgra64_to_bgra32; //----color_conv_bgra64_to_bgra32
|
||||
typedef color_conv_rgba64_rgba32<0,1,2,3> color_conv_abgr64_to_abgr32; //----color_conv_abgr64_to_abgr32
|
||||
typedef color_conv_rgba64_rgba32<0,3,2,1> color_conv_argb64_to_abgr32; //----color_conv_argb64_to_abgr32
|
||||
typedef color_conv_rgba64_rgba32<3,2,1,0> color_conv_argb64_to_bgra32; //----color_conv_argb64_to_bgra32
|
||||
typedef color_conv_rgba64_rgba32<1,2,3,0> color_conv_argb64_to_rgba32; //----color_conv_argb64_to_rgba32
|
||||
typedef color_conv_rgba64_rgba32<3,0,1,2> color_conv_bgra64_to_abgr32; //----color_conv_bgra64_to_abgr32
|
||||
typedef color_conv_rgba64_rgba32<3,2,1,0> color_conv_bgra64_to_argb32; //----color_conv_bgra64_to_argb32
|
||||
typedef color_conv_rgba64_rgba32<2,1,0,3> color_conv_bgra64_to_rgba32; //----color_conv_bgra64_to_rgba32
|
||||
typedef color_conv_rgba64_rgba32<3,2,1,0> color_conv_rgba64_to_abgr32; //----color_conv_rgba64_to_abgr32
|
||||
typedef color_conv_rgba64_rgba32<3,0,1,2> color_conv_rgba64_to_argb32; //----color_conv_rgba64_to_argb32
|
||||
typedef color_conv_rgba64_rgba32<2,1,0,3> color_conv_rgba64_to_bgra32; //----color_conv_rgba64_to_bgra32
|
||||
typedef color_conv_rgba64_rgba32<0,3,2,1> color_conv_abgr64_to_argb32; //----color_conv_abgr64_to_argb32
|
||||
typedef color_conv_rgba64_rgba32<1,2,3,0> color_conv_abgr64_to_bgra32; //----color_conv_abgr64_to_bgra32
|
||||
typedef color_conv_rgba64_rgba32<3,2,1,0> color_conv_abgr64_to_rgba32; //----color_conv_abgr64_to_rgba32
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------color_conv_rgb24_rgba64
|
||||
template<int I1, int I2, int I3, int A> class color_conv_rgb24_rgba64
|
||||
{
|
||||
public:
|
||||
void operator () (int8u* dst,
|
||||
const int8u* src,
|
||||
unsigned width) const
|
||||
{
|
||||
int16u* d = (int16u*)dst;
|
||||
do
|
||||
{
|
||||
d[I1] = (src[0] << 8) | src[0];
|
||||
d[I2] = (src[1] << 8) | src[1];
|
||||
d[I3] = (src[2] << 8) | src[2];
|
||||
d[A] = 65535;
|
||||
d += 4;
|
||||
src += 3;
|
||||
}
|
||||
while(--width);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
typedef color_conv_rgb24_rgba64<1,2,3,0> color_conv_rgb24_to_argb64; //----color_conv_rgb24_to_argb64
|
||||
typedef color_conv_rgb24_rgba64<3,2,1,0> color_conv_rgb24_to_abgr64; //----color_conv_rgb24_to_abgr64
|
||||
typedef color_conv_rgb24_rgba64<2,1,0,3> color_conv_rgb24_to_bgra64; //----color_conv_rgb24_to_bgra64
|
||||
typedef color_conv_rgb24_rgba64<0,1,2,3> color_conv_rgb24_to_rgba64; //----color_conv_rgb24_to_rgba64
|
||||
typedef color_conv_rgb24_rgba64<3,2,1,0> color_conv_bgr24_to_argb64; //----color_conv_bgr24_to_argb64
|
||||
typedef color_conv_rgb24_rgba64<1,2,3,0> color_conv_bgr24_to_abgr64; //----color_conv_bgr24_to_abgr64
|
||||
typedef color_conv_rgb24_rgba64<0,1,2,3> color_conv_bgr24_to_bgra64; //----color_conv_bgr24_to_bgra64
|
||||
typedef color_conv_rgb24_rgba64<2,1,0,3> color_conv_bgr24_to_rgba64; //----color_conv_bgr24_to_rgba64
|
||||
|
||||
|
||||
template<int R, int B> class color_conv_rgb24_gray16
|
||||
{
|
||||
public:
|
||||
void operator () (int8u* dst,
|
||||
const int8u* src,
|
||||
unsigned width) const
|
||||
{
|
||||
int16u* d = (int16u*)dst;
|
||||
do
|
||||
{
|
||||
*d++ = src[R]*77 + src[1]*150 + src[B]*29;
|
||||
src += 3;
|
||||
}
|
||||
while(--width);
|
||||
}
|
||||
};
|
||||
|
||||
typedef color_conv_rgb24_gray16<0,2> color_conv_rgb24_to_gray16;
|
||||
typedef color_conv_rgb24_gray16<2,0> color_conv_bgr24_to_gray16;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
469
3party/agg/util/agg_color_conv_rgb8.h
Normal file
469
3party/agg/util/agg_color_conv_rgb8.h
Normal file
|
|
@ -0,0 +1,469 @@
|
|||
//----------------------------------------------------------------------------
|
||||
// Anti-Grain Geometry - Version 2.4
|
||||
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
|
||||
//
|
||||
// Permission to copy, use, modify, sell and distribute this software
|
||||
// is granted provided this copyright notice appears in all copies.
|
||||
// This software is provided "as is" without express or implied
|
||||
// warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
// Contact: mcseem@antigrain.com
|
||||
// mcseemagg@yahoo.com
|
||||
// http://www.antigrain.com
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// A set of functors used with color_conv(). See file agg_color_conv.h
|
||||
// These functors can convert images with up to 8 bits per component.
|
||||
// Use convertors in the following way:
|
||||
//
|
||||
// agg::color_conv(dst, src, agg::color_conv_XXXX_to_YYYY());
|
||||
// whare XXXX and YYYY can be any of:
|
||||
// rgb24
|
||||
// bgr24
|
||||
// rgba32
|
||||
// abgr32
|
||||
// argb32
|
||||
// bgra32
|
||||
// rgb555
|
||||
// rgb565
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifndef AGG_COLOR_CONV_RGB8_INCLUDED
|
||||
#define AGG_COLOR_CONV_RGB8_INCLUDED
|
||||
|
||||
#include "agg_basics.h"
|
||||
#include "agg_color_conv.h"
|
||||
|
||||
namespace agg
|
||||
{
|
||||
|
||||
//-----------------------------------------------------color_conv_rgb24
|
||||
class color_conv_rgb24
|
||||
{
|
||||
public:
|
||||
void operator () (int8u* dst,
|
||||
const int8u* src,
|
||||
unsigned width) const
|
||||
{
|
||||
do
|
||||
{
|
||||
*dst++ = src[2];
|
||||
*dst++ = src[1];
|
||||
*dst++ = src[0];
|
||||
src += 3;
|
||||
}
|
||||
while(--width);
|
||||
}
|
||||
};
|
||||
|
||||
typedef color_conv_rgb24 color_conv_rgb24_to_bgr24;
|
||||
typedef color_conv_rgb24 color_conv_bgr24_to_rgb24;
|
||||
|
||||
typedef color_conv_same<3> color_conv_bgr24_to_bgr24;
|
||||
typedef color_conv_same<3> color_conv_rgb24_to_rgb24;
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------color_conv_rgba32
|
||||
template<int I1, int I2, int I3, int I4> class color_conv_rgba32
|
||||
{
|
||||
public:
|
||||
void operator () (int8u* dst,
|
||||
const int8u* src,
|
||||
unsigned width) const
|
||||
{
|
||||
do
|
||||
{
|
||||
*dst++ = src[I1];
|
||||
*dst++ = src[I2];
|
||||
*dst++ = src[I3];
|
||||
*dst++ = src[I4];
|
||||
src += 4;
|
||||
}
|
||||
while(--width);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
typedef color_conv_rgba32<0,3,2,1> color_conv_argb32_to_abgr32; //----color_conv_argb32_to_abgr32
|
||||
typedef color_conv_rgba32<3,2,1,0> color_conv_argb32_to_bgra32; //----color_conv_argb32_to_bgra32
|
||||
typedef color_conv_rgba32<1,2,3,0> color_conv_argb32_to_rgba32; //----color_conv_argb32_to_rgba32
|
||||
typedef color_conv_rgba32<3,0,1,2> color_conv_bgra32_to_abgr32; //----color_conv_bgra32_to_abgr32
|
||||
typedef color_conv_rgba32<3,2,1,0> color_conv_bgra32_to_argb32; //----color_conv_bgra32_to_argb32
|
||||
typedef color_conv_rgba32<2,1,0,3> color_conv_bgra32_to_rgba32; //----color_conv_bgra32_to_rgba32
|
||||
typedef color_conv_rgba32<3,2,1,0> color_conv_rgba32_to_abgr32; //----color_conv_rgba32_to_abgr32
|
||||
typedef color_conv_rgba32<3,0,1,2> color_conv_rgba32_to_argb32; //----color_conv_rgba32_to_argb32
|
||||
typedef color_conv_rgba32<2,1,0,3> color_conv_rgba32_to_bgra32; //----color_conv_rgba32_to_bgra32
|
||||
typedef color_conv_rgba32<0,3,2,1> color_conv_abgr32_to_argb32; //----color_conv_abgr32_to_argb32
|
||||
typedef color_conv_rgba32<1,2,3,0> color_conv_abgr32_to_bgra32; //----color_conv_abgr32_to_bgra32
|
||||
typedef color_conv_rgba32<3,2,1,0> color_conv_abgr32_to_rgba32; //----color_conv_abgr32_to_rgba32
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
typedef color_conv_same<4> color_conv_rgba32_to_rgba32; //----color_conv_rgba32_to_rgba32
|
||||
typedef color_conv_same<4> color_conv_argb32_to_argb32; //----color_conv_argb32_to_argb32
|
||||
typedef color_conv_same<4> color_conv_bgra32_to_bgra32; //----color_conv_bgra32_to_bgra32
|
||||
typedef color_conv_same<4> color_conv_abgr32_to_abgr32; //----color_conv_abgr32_to_abgr32
|
||||
|
||||
|
||||
//--------------------------------------------color_conv_rgb24_rgba32
|
||||
template<int I1, int I2, int I3, int A> class color_conv_rgb24_rgba32
|
||||
{
|
||||
public:
|
||||
void operator () (int8u* dst,
|
||||
const int8u* src,
|
||||
unsigned width) const
|
||||
{
|
||||
do
|
||||
{
|
||||
dst[I1] = *src++;
|
||||
dst[I2] = *src++;
|
||||
dst[I3] = *src++;
|
||||
dst[A] = 255;
|
||||
dst += 4;
|
||||
}
|
||||
while(--width);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
typedef color_conv_rgb24_rgba32<1,2,3,0> color_conv_rgb24_to_argb32; //----color_conv_rgb24_to_argb32
|
||||
typedef color_conv_rgb24_rgba32<3,2,1,0> color_conv_rgb24_to_abgr32; //----color_conv_rgb24_to_abgr32
|
||||
typedef color_conv_rgb24_rgba32<2,1,0,3> color_conv_rgb24_to_bgra32; //----color_conv_rgb24_to_bgra32
|
||||
typedef color_conv_rgb24_rgba32<0,1,2,3> color_conv_rgb24_to_rgba32; //----color_conv_rgb24_to_rgba32
|
||||
typedef color_conv_rgb24_rgba32<3,2,1,0> color_conv_bgr24_to_argb32; //----color_conv_bgr24_to_argb32
|
||||
typedef color_conv_rgb24_rgba32<1,2,3,0> color_conv_bgr24_to_abgr32; //----color_conv_bgr24_to_abgr32
|
||||
typedef color_conv_rgb24_rgba32<0,1,2,3> color_conv_bgr24_to_bgra32; //----color_conv_bgr24_to_bgra32
|
||||
typedef color_conv_rgb24_rgba32<2,1,0,3> color_conv_bgr24_to_rgba32; //----color_conv_bgr24_to_rgba32
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------color_conv_rgba32_rgb24
|
||||
template<int I1, int I2, int I3> class color_conv_rgba32_rgb24
|
||||
{
|
||||
public:
|
||||
void operator () (int8u* dst,
|
||||
const int8u* src,
|
||||
unsigned width) const
|
||||
{
|
||||
do
|
||||
{
|
||||
*dst++ = src[I1];
|
||||
*dst++ = src[I2];
|
||||
*dst++ = src[I3];
|
||||
src += 4;
|
||||
}
|
||||
while(--width);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
typedef color_conv_rgba32_rgb24<1,2,3> color_conv_argb32_to_rgb24; //----color_conv_argb32_to_rgb24
|
||||
typedef color_conv_rgba32_rgb24<3,2,1> color_conv_abgr32_to_rgb24; //----color_conv_abgr32_to_rgb24
|
||||
typedef color_conv_rgba32_rgb24<2,1,0> color_conv_bgra32_to_rgb24; //----color_conv_bgra32_to_rgb24
|
||||
typedef color_conv_rgba32_rgb24<0,1,2> color_conv_rgba32_to_rgb24; //----color_conv_rgba32_to_rgb24
|
||||
typedef color_conv_rgba32_rgb24<3,2,1> color_conv_argb32_to_bgr24; //----color_conv_argb32_to_bgr24
|
||||
typedef color_conv_rgba32_rgb24<1,2,3> color_conv_abgr32_to_bgr24; //----color_conv_abgr32_to_bgr24
|
||||
typedef color_conv_rgba32_rgb24<0,1,2> color_conv_bgra32_to_bgr24; //----color_conv_bgra32_to_bgr24
|
||||
typedef color_conv_rgba32_rgb24<2,1,0> color_conv_rgba32_to_bgr24; //----color_conv_rgba32_to_bgr24
|
||||
|
||||
|
||||
//------------------------------------------------color_conv_rgb555_rgb24
|
||||
template<int R, int B> class color_conv_rgb555_rgb24
|
||||
{
|
||||
public:
|
||||
void operator () (int8u* dst,
|
||||
const int8u* src,
|
||||
unsigned width) const
|
||||
{
|
||||
do
|
||||
{
|
||||
unsigned rgb = *(int16u*)src;
|
||||
dst[R] = (int8u)((rgb >> 7) & 0xF8);
|
||||
dst[1] = (int8u)((rgb >> 2) & 0xF8);
|
||||
dst[B] = (int8u)((rgb << 3) & 0xF8);
|
||||
src += 2;
|
||||
dst += 3;
|
||||
}
|
||||
while(--width);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
typedef color_conv_rgb555_rgb24<2,0> color_conv_rgb555_to_bgr24; //----color_conv_rgb555_to_bgr24
|
||||
typedef color_conv_rgb555_rgb24<0,2> color_conv_rgb555_to_rgb24; //----color_conv_rgb555_to_rgb24
|
||||
|
||||
|
||||
//-------------------------------------------------color_conv_rgb24_rgb555
|
||||
template<int R, int B> class color_conv_rgb24_rgb555
|
||||
{
|
||||
public:
|
||||
void operator () (int8u* dst,
|
||||
const int8u* src,
|
||||
unsigned width) const
|
||||
{
|
||||
do
|
||||
{
|
||||
*(int16u*)dst = (int16u)(((unsigned(src[R]) << 7) & 0x7C00) |
|
||||
((unsigned(src[1]) << 2) & 0x3E0) |
|
||||
((unsigned(src[B]) >> 3)));
|
||||
src += 3;
|
||||
dst += 2;
|
||||
}
|
||||
while(--width);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
typedef color_conv_rgb24_rgb555<2,0> color_conv_bgr24_to_rgb555; //----color_conv_bgr24_to_rgb555
|
||||
typedef color_conv_rgb24_rgb555<0,2> color_conv_rgb24_to_rgb555; //----color_conv_rgb24_to_rgb555
|
||||
|
||||
|
||||
//-------------------------------------------------color_conv_rgb565_rgb24
|
||||
template<int R, int B> class color_conv_rgb565_rgb24
|
||||
{
|
||||
public:
|
||||
void operator () (int8u* dst,
|
||||
const int8u* src,
|
||||
unsigned width) const
|
||||
{
|
||||
do
|
||||
{
|
||||
unsigned rgb = *(int16u*)src;
|
||||
dst[R] = (rgb >> 8) & 0xF8;
|
||||
dst[1] = (rgb >> 3) & 0xFC;
|
||||
dst[B] = (rgb << 3) & 0xF8;
|
||||
src += 2;
|
||||
dst += 3;
|
||||
}
|
||||
while(--width);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
typedef color_conv_rgb565_rgb24<2,0> color_conv_rgb565_to_bgr24; //----color_conv_rgb565_to_bgr24
|
||||
typedef color_conv_rgb565_rgb24<0,2> color_conv_rgb565_to_rgb24; //----color_conv_rgb565_to_rgb24
|
||||
|
||||
|
||||
//-------------------------------------------------color_conv_rgb24_rgb565
|
||||
template<int R, int B> class color_conv_rgb24_rgb565
|
||||
{
|
||||
public:
|
||||
void operator () (int8u* dst,
|
||||
const int8u* src,
|
||||
unsigned width) const
|
||||
{
|
||||
do
|
||||
{
|
||||
*(int16u*)dst = (int16u)(((unsigned(src[R]) << 8) & 0xF800) |
|
||||
((unsigned(src[1]) << 3) & 0x7E0) |
|
||||
((unsigned(src[B]) >> 3)));
|
||||
src += 3;
|
||||
dst += 2;
|
||||
}
|
||||
while(--width);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
typedef color_conv_rgb24_rgb565<2,0> color_conv_bgr24_to_rgb565; //----color_conv_bgr24_to_rgb565
|
||||
typedef color_conv_rgb24_rgb565<0,2> color_conv_rgb24_to_rgb565; //----color_conv_rgb24_to_rgb565
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------color_conv_rgb555_rgba32
|
||||
template<int R, int G, int B, int A> class color_conv_rgb555_rgba32
|
||||
{
|
||||
public:
|
||||
void operator () (int8u* dst,
|
||||
const int8u* src,
|
||||
unsigned width) const
|
||||
{
|
||||
do
|
||||
{
|
||||
int rgb = *(int16*)src;
|
||||
dst[R] = (int8u)((rgb >> 7) & 0xF8);
|
||||
dst[G] = (int8u)((rgb >> 2) & 0xF8);
|
||||
dst[B] = (int8u)((rgb << 3) & 0xF8);
|
||||
dst[A] = (int8u)(rgb >> 15);
|
||||
src += 2;
|
||||
dst += 4;
|
||||
}
|
||||
while(--width);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
typedef color_conv_rgb555_rgba32<1,2,3,0> color_conv_rgb555_to_argb32; //----color_conv_rgb555_to_argb32
|
||||
typedef color_conv_rgb555_rgba32<3,2,1,0> color_conv_rgb555_to_abgr32; //----color_conv_rgb555_to_abgr32
|
||||
typedef color_conv_rgb555_rgba32<2,1,0,3> color_conv_rgb555_to_bgra32; //----color_conv_rgb555_to_bgra32
|
||||
typedef color_conv_rgb555_rgba32<0,1,2,3> color_conv_rgb555_to_rgba32; //----color_conv_rgb555_to_rgba32
|
||||
|
||||
|
||||
//------------------------------------------------color_conv_rgba32_rgb555
|
||||
template<int R, int G, int B, int A> class color_conv_rgba32_rgb555
|
||||
{
|
||||
public:
|
||||
void operator () (int8u* dst,
|
||||
const int8u* src,
|
||||
unsigned width) const
|
||||
{
|
||||
do
|
||||
{
|
||||
*(int16u*)dst = (int16u)(((unsigned(src[R]) << 7) & 0x7C00) |
|
||||
((unsigned(src[G]) << 2) & 0x3E0) |
|
||||
((unsigned(src[B]) >> 3)) |
|
||||
((unsigned(src[A]) << 8) & 0x8000));
|
||||
src += 4;
|
||||
dst += 2;
|
||||
}
|
||||
while(--width);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
typedef color_conv_rgba32_rgb555<1,2,3,0> color_conv_argb32_to_rgb555; //----color_conv_argb32_to_rgb555
|
||||
typedef color_conv_rgba32_rgb555<3,2,1,0> color_conv_abgr32_to_rgb555; //----color_conv_abgr32_to_rgb555
|
||||
typedef color_conv_rgba32_rgb555<2,1,0,3> color_conv_bgra32_to_rgb555; //----color_conv_bgra32_to_rgb555
|
||||
typedef color_conv_rgba32_rgb555<0,1,2,3> color_conv_rgba32_to_rgb555; //----color_conv_rgba32_to_rgb555
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------color_conv_rgb565_rgba32
|
||||
template<int R, int G, int B, int A> class color_conv_rgb565_rgba32
|
||||
{
|
||||
public:
|
||||
void operator () (int8u* dst,
|
||||
const int8u* src,
|
||||
unsigned width) const
|
||||
{
|
||||
do
|
||||
{
|
||||
int rgb = *(int16*)src;
|
||||
dst[R] = (rgb >> 8) & 0xF8;
|
||||
dst[G] = (rgb >> 3) & 0xFC;
|
||||
dst[B] = (rgb << 3) & 0xF8;
|
||||
dst[A] = 255;
|
||||
src += 2;
|
||||
dst += 4;
|
||||
}
|
||||
while(--width);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
typedef color_conv_rgb565_rgba32<1,2,3,0> color_conv_rgb565_to_argb32; //----color_conv_rgb565_to_argb32
|
||||
typedef color_conv_rgb565_rgba32<3,2,1,0> color_conv_rgb565_to_abgr32; //----color_conv_rgb565_to_abgr32
|
||||
typedef color_conv_rgb565_rgba32<2,1,0,3> color_conv_rgb565_to_bgra32; //----color_conv_rgb565_to_bgra32
|
||||
typedef color_conv_rgb565_rgba32<0,1,2,3> color_conv_rgb565_to_rgba32; //----color_conv_rgb565_to_rgba32
|
||||
|
||||
|
||||
//------------------------------------------------color_conv_rgba32_rgb565
|
||||
template<int R, int G, int B> class color_conv_rgba32_rgb565
|
||||
{
|
||||
public:
|
||||
void operator () (int8u* dst,
|
||||
const int8u* src,
|
||||
unsigned width) const
|
||||
{
|
||||
do
|
||||
{
|
||||
*(int16u*)dst = (int16u)(((unsigned(src[R]) << 8) & 0xF800) |
|
||||
((unsigned(src[G]) << 3) & 0x7E0) |
|
||||
((unsigned(src[B]) >> 3)));
|
||||
src += 4;
|
||||
dst += 2;
|
||||
}
|
||||
while(--width);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
typedef color_conv_rgba32_rgb565<1,2,3> color_conv_argb32_to_rgb565; //----color_conv_argb32_to_rgb565
|
||||
typedef color_conv_rgba32_rgb565<3,2,1> color_conv_abgr32_to_rgb565; //----color_conv_abgr32_to_rgb565
|
||||
typedef color_conv_rgba32_rgb565<2,1,0> color_conv_bgra32_to_rgb565; //----color_conv_bgra32_to_rgb565
|
||||
typedef color_conv_rgba32_rgb565<0,1,2> color_conv_rgba32_to_rgb565; //----color_conv_rgba32_to_rgb565
|
||||
|
||||
|
||||
//---------------------------------------------color_conv_rgb555_to_rgb565
|
||||
class color_conv_rgb555_to_rgb565
|
||||
{
|
||||
public:
|
||||
void operator () (int8u* dst,
|
||||
const int8u* src,
|
||||
unsigned width) const
|
||||
{
|
||||
do
|
||||
{
|
||||
unsigned rgb = *(int16u*)src;
|
||||
*(int16u*)dst = (int16u)(((rgb << 1) & 0xFFC0) | (rgb & 0x1F));
|
||||
src += 2;
|
||||
dst += 2;
|
||||
}
|
||||
while(--width);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//----------------------------------------------color_conv_rgb565_to_rgb555
|
||||
class color_conv_rgb565_to_rgb555
|
||||
{
|
||||
public:
|
||||
void operator () (int8u* dst,
|
||||
const int8u* src,
|
||||
unsigned width) const
|
||||
{
|
||||
do
|
||||
{
|
||||
unsigned rgb = *(int16u*)src;
|
||||
*(int16u*)dst = (int16u)(((rgb >> 1) & 0x7FE0) | (rgb & 0x1F));
|
||||
src += 2;
|
||||
dst += 2;
|
||||
}
|
||||
while(--width);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
typedef color_conv_same<2> color_conv_rgb555_to_rgb555; //----color_conv_rgb555_to_rgb555
|
||||
typedef color_conv_same<2> color_conv_rgb565_to_rgb565; //----color_conv_rgb565_to_rgb565
|
||||
|
||||
|
||||
template<int R, int B> class color_conv_rgb24_gray8
|
||||
{
|
||||
public:
|
||||
void operator () (int8u* dst,
|
||||
const int8u* src,
|
||||
unsigned width) const
|
||||
{
|
||||
do
|
||||
{
|
||||
*dst++ = (src[R]*77 + src[1]*150 + src[B]*29) >> 8;
|
||||
src += 3;
|
||||
}
|
||||
while(--width);
|
||||
}
|
||||
};
|
||||
|
||||
typedef color_conv_rgb24_gray8<0,2> color_conv_rgb24_to_gray8; //----color_conv_rgb24_to_gray8
|
||||
typedef color_conv_rgb24_gray8<2,0> color_conv_bgr24_to_gray8; //----color_conv_bgr24_to_gray8
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue