30 #ifndef PT_GFX_COPYPIXEL_H
31 #define PT_GFX_COPYPIXEL_H
33 #include <Pt/Gfx/Api.h>
34 #include <Pt/Gfx/ConvertColor.h>
35 #include <Pt/Gfx/ImageTraits.h>
36 #include <Pt/TypeTraits.h>
49 template <
typename Fmt1,
typename Fmt2>
52 template <
typename P1,
typename P2>
53 static void convert(
const P1& from, P2& to)
55 typedef typename P2::ColorType ColorType;
57 to = convertColor<ColorType>( from.getColor() );
60 template <
typename P1,
typename P2>
61 static void convert(
const P1& from, P2& to, std::size_t length)
63 typedef typename P1::ColorType ColorT1;
64 typedef typename P2::ColorType ColorT2;
66 convertImpl(from, to, length, IsSame<ColorT1, ColorT2>());
69 template <
typename P1,
typename P2>
70 static void convertImpl(
const P1& from, P2& to, std::size_t length, TrueType)
72 typedef typename P1::ColorType ColorType;
74 const std::size_t bufsize = 64;
75 ColorType colors[bufsize];
82 std::size_t n = std::min(length, bufsize);
84 f.getColors(colors, n);
94 template <
typename P1,
typename P2>
95 static void convertImpl(
const P1& from, P2& to, std::size_t length, FalseType)
97 typedef typename P1::ColorType ColorT1;
98 typedef typename P2::ColorType ColorT2;
100 const std::size_t bufsize = 64;
101 ColorT1 fromColors[bufsize];
102 ColorT2 toColors[bufsize];
109 std::size_t n = std::min(length, bufsize);
111 f.getColors(fromColors, n);
112 convertColors(toColors, fromColors, n);
113 t.assign(toColors, n);
123 template <
typename Fmt>
124 struct PixelConverter<Fmt, Fmt>
126 template <
typename P1,
typename P2>
127 static void convert(
const P1& from, P2& to)
132 template <
typename P1,
typename P2>
133 static void convert(
const P1& from, P2& to, std::size_t length)
135 to.assign(from, length);
145 template <
typename P1,
typename P2>
148 typedef typename P1::FormatType Fmt1;
149 typedef typename P2::FormatType Fmt2;
151 PixelConverter<Fmt1, Fmt2>::convert(from, to);
156 template <
typename P1,
typename P2>
157 void copyPixel(
const P1& from, P2& to, std::size_t length)
159 typedef typename P1::FormatType Fmt1;
160 typedef typename P2::FormatType Fmt2;
162 PixelConverter<Fmt1, Fmt2>::convert(from, to, length);
void copyPixel(const P1 &from, P2 &to)
Copies a single pixel.
Definition: CopyPixel.h:146