23 template <
class T1,
class T2>
24 static inline void CopyPixel(
const T1 *src, T2 *dest)
120 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
130 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
142 *dest =
static_cast<char>((src->
r + src->
g + src->
b)/3);
177 *dest = ((src->
r + src->
g + src->
b)/3.0f);
298 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
308 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
318 *dest =
static_cast<char>((src->
r + src->
g + src->
b)/3);
330 *dest = ((src->
r + src->
g + src->
b)/3.0f);
379 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
389 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
399 *dest =
static_cast<char>((src->
r + src->
g + src->
b)/3);
411 *dest = ((src->
r + src->
g + src->
b)/3.0f);
459 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
469 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
479 *dest =
static_cast<char>((src->
r + src->
g + src->
b)/3);
491 *dest = ((src->
r + src->
g + src->
b)/3.0f);
539 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
549 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
559 *dest =
static_cast<char>((src->
r + src->
g + src->
b)/3);
564 dest->
r =
static_cast<char>(src->
r);
565 dest->
g =
static_cast<char>(src->
g);
566 dest->
b =
static_cast<char>(src->
b);
571 *dest = ((src->
r + src->
g + src->
b)/3.0f);
576 dest->
r =
static_cast<float>(
static_cast<int>(src->
r));
577 dest->
g =
static_cast<float>(
static_cast<int>(src->
g));
578 dest->
b =
static_cast<float>(
static_cast<int>(src->
b));
583 dest->
r =
static_cast<unsigned char>(src->
r);
584 dest->
g =
static_cast<unsigned char>(src->
g);
585 dest->
b =
static_cast<unsigned char>(src->
b);
590 dest->
r =
static_cast<unsigned char>(src->
r);
591 dest->
g =
static_cast<unsigned char>(src->
g);
592 dest->
b =
static_cast<unsigned char>(src->
b);
597 dest->
r =
static_cast<unsigned char>(src->
r);
598 dest->
g =
static_cast<unsigned char>(src->
g);
599 dest->
b =
static_cast<unsigned char>(src->
b);
605 dest->
r =
static_cast<unsigned char>(src->
r);
606 dest->
g =
static_cast<unsigned char>(src->
g);
607 dest->
b =
static_cast<unsigned char>(src->
b);
702 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
712 *dest =
static_cast<int>((src->
r + src->
g + src->
b)/3);
722 *dest =
static_cast<char>((src->
r + src->
g + src->
b)/3);
764 *dest = ((src->
r + src->
g + src->
b)/3.0f);
783 *dest =
static_cast<unsigned char>(*src);
793 *dest =
static_cast<unsigned char>(*src);
798 *dest =
static_cast<char>(*src);
803 dest->
r =
static_cast<unsigned char>(*src);
804 dest->
g =
static_cast<unsigned char>(*src);
805 dest->
b =
static_cast<unsigned char>(*src);
810 dest->
r =
static_cast<unsigned char>(*src);
811 dest->
g =
static_cast<unsigned char>(*src);
812 dest->
b =
static_cast<unsigned char>(*src);
818 dest->
r =
static_cast<unsigned char>(*src);
819 dest->
g =
static_cast<unsigned char>(*src);
820 dest->
b =
static_cast<unsigned char>(*src);
826 dest->
r =
static_cast<int>(*src);
827 dest->
g =
static_cast<int>(*src);
828 dest->
b =
static_cast<int>(*src);
833 dest->
r =
static_cast<unsigned char>(*src);
834 dest->
g =
static_cast<unsigned char>(*src);
835 dest->
b =
static_cast<unsigned char>(*src);
840 dest->
v =
static_cast<unsigned char>(*src);
847 dest->
r =
static_cast<signed char>(*src);
848 dest->
g =
static_cast<signed char>(*src);
849 dest->
b =
static_cast<signed char>(*src);
870 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
875 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
890 *dest =
static_cast<char>((src->
r + src->
g + src->
b)/3);
895 dest->
r =
static_cast<unsigned char>(src->
r);
896 dest->
g =
static_cast<unsigned char>(src->
g);
897 dest->
b =
static_cast<unsigned char>(src->
b);
902 dest->
r =
static_cast<unsigned char>(src->
r);
903 dest->
g =
static_cast<unsigned char>(src->
g);
904 dest->
b =
static_cast<unsigned char>(src->
b);
910 dest->
r =
static_cast<unsigned char>(src->
r);
911 dest->
g =
static_cast<unsigned char>(src->
g);
912 dest->
b =
static_cast<unsigned char>(src->
b);
918 dest->
r =
static_cast<int>(src->
r);
919 dest->
g =
static_cast<int>(src->
g);
920 dest->
b =
static_cast<int>(src->
b);
925 dest->
r =
static_cast<unsigned char>(src->
r);
926 dest->
g =
static_cast<unsigned char>(src->
g);
927 dest->
b =
static_cast<unsigned char>(src->
b);
932 *dest = ((src->
r + src->
g + src->
b)/3);
937 dest->
r =
static_cast<signed char>(src->
r);
938 dest->
g =
static_cast<signed char>(src->
g);
939 dest->
b =
static_cast<signed char>(src->
b);
1018 dest->
r =
static_cast<char>(*src);
1019 dest->
g =
static_cast<char>(*src);
1020 dest->
b =
static_cast<char>(*src);
1025 dest->
r =
static_cast<char>(*src);
1026 dest->
g =
static_cast<char>(*src);
1027 dest->
b =
static_cast<char>(*src);
1033 dest->
r =
static_cast<char>(*src);
1034 dest->
g =
static_cast<char>(*src);
1035 dest->
b =
static_cast<char>(*src);
1048 dest->
r =
static_cast<char>(*src);
1049 dest->
g =
static_cast<char>(*src);
1050 dest->
b =
static_cast<char>(*src);
1056 dest->
h = dest->
s = 0;
1068 *dest =
static_cast<float>(*src);
1073 dest->
r =
static_cast<float>(*src);
1074 dest->
g =
static_cast<float>(*src);
1075 dest->
b =
static_cast<float>(*src);
1080 dest->
v = float(*src);
1087 *dest =
static_cast<char>(*src >> 1);
1104 dest->
r =
static_cast<char>(*src);
1105 dest->
g =
static_cast<char>(*src);
1106 dest->
b =
static_cast<char>(*src);
1111 dest->
r =
static_cast<char>(*src);
1112 dest->
g =
static_cast<char>(*src);
1113 dest->
b =
static_cast<char>(*src);
1119 dest->
r =
static_cast<char>(*src);
1120 dest->
g =
static_cast<char>(*src);
1121 dest->
b =
static_cast<char>(*src);
1127 dest->
r =
static_cast<int>(
static_cast<unsigned>(*src));
1128 dest->
g =
static_cast<int>(
static_cast<unsigned>(*src));
1129 dest->
b =
static_cast<int>(
static_cast<unsigned>(*src));
1134 *dest =
static_cast<int>(
static_cast<unsigned>(*src));
1139 dest->
r =
static_cast<char>(*src);
1140 dest->
g =
static_cast<char>(*src);
1141 dest->
b =
static_cast<char>(*src);
1160 *dest =
static_cast<float>(*src);
1165 dest->
r =
static_cast<float>(*src);
1166 dest->
g =
static_cast<float>(*src);
1167 dest->
b =
static_cast<float>(*src);
1172 dest->
v =
static_cast<float>(*src);
1179 *dest =
static_cast<char>(*src >> 1);
1203 template <
class T1,
class T2>
1204 static void CopyPixels(
const T1 *osrc,
int q1, T2 *odest,
int q2,
1208 const T1 *src = osrc;
1210 const int p1 =
PAD_BYTES (w *
sizeof(T1), q1);
1211 const int p2 =
PAD_BYTES (w *
sizeof(T2), q2);
1213 const int step2 = w*
sizeof(T2) + p2;
1214 DBG printf(
"q1 %d q2 %d (%dx%d) inc %d %d\n", q1, q2, w, h, p1, p2);
1217 odest =
reinterpret_cast<T2*
>(((
char *)odest) + step2*(h-1));
1221 for (
int i=0; i<h; i++) {
1222 DBG printf(
"x,y = %d,%d\n", 0,i);
1223 for (
int j = 0; j < w; j++) {
1229 src =
reinterpret_cast<const T1*
>(((
char *)src) + p1);
1230 odest =
reinterpret_cast<T2*
>(((
char *)odest) + step2*(flip?-1:1));
1251 #define HASH(id1, id2) ((int)(((int)(id1%65537))*11 + ((long int)(id2))))
1252 #define HANDLE_CASE(len, x1, T1, q1, o1, x2, T2, q2, o2) CopyPixels(reinterpret_cast<const T1*>(x1), q1, reinterpret_cast<T2*>(x2), q2, w, h, o1!=o2);
1253 #define MAKE_CASE(id1, id2) case HASH(id1, id2): HANDLE_CASE(len, src, Def_##id1, quantum1, topIsLow1, dest, Def_##id2, quantum2, topIsLow2); break;
1256 void Image::copyPixels(
const unsigned char *src,
size_t id1,
1257 char unsigned *dest,
size_t id2,
size_t w,
size_t h,
1258 size_t imageSize,
size_t quantum1,
size_t quantum2,
1259 bool topIsLow1,
bool topIsLow2)
1261 DBG printf(
"copyPixels...\n");
1263 if (id1==id2&&quantum1==quantum2&&topIsLow1==topIsLow2) {
1264 memcpy(dest,src,imageSize);
1269 switch(
HASH(id1,id2)) {
1491 printf(
"*** Tried to copy type %s to %s\n",
1498 DBG printf(
"... done copyPixels\n");
PixelFloat Def_VOCAB_PIXEL_MONO_FLOAT
#define MAKE_CASE(id1, id2)
static void CopyPixel(const T1 *src, T2 *dest)
PixelInt Def_VOCAB_PIXEL_INT
static void CopyPixels(const T1 *osrc, int q1, T2 *odest, int q2, int w, int h, bool flip)
PixelMono Def_VOCAB_PIXEL_MONO
PixelMono16 Def_VOCAB_PIXEL_MONO16
PixelMonoSigned Def_VOCAB_PIXEL_MONO_SIGNED
@ VOCAB_PIXEL_MONO_SIGNED
std::string decode(NetInt32 code)
Convert a vocabulary identifier into a string.
char PixelMonoSigned
Signed byte pixel type.
size_t PAD_BYTES(size_t len, size_t pad)
computes the padding of YARP images.
yarp::os::NetUint16 PixelMono16
16-bit monochrome pixel type.
unsigned char PixelMono
Monochrome pixel type.
float PixelFloat
Floating point pixel type.
yarp::os::NetInt32 PixelInt
32-bit integer pixel type.
Packed RGB pixel type, with pixels stored in reverse order.
Floating point HSV pixel type.
Packed HSV (hue/saturation/value pixel type.
Floating point RGB pixel type.
Signed, packed RGB pixel type.