20 template <
class T1,
class T2>
21 static inline void CopyPixel(
const T1 *src, T2 *dest)
117 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
127 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
139 *dest =
static_cast<char>((src->
r + src->
g + src->
b)/3);
174 *dest = ((src->
r + src->
g + src->
b)/3.0f);
295 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
305 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
315 *dest =
static_cast<char>((src->
r + src->
g + src->
b)/3);
327 *dest = ((src->
r + src->
g + src->
b)/3.0f);
376 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
386 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
396 *dest =
static_cast<char>((src->
r + src->
g + src->
b)/3);
408 *dest = ((src->
r + src->
g + src->
b)/3.0f);
456 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
466 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
476 *dest =
static_cast<char>((src->
r + src->
g + src->
b)/3);
488 *dest = ((src->
r + src->
g + src->
b)/3.0f);
536 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
546 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
556 *dest =
static_cast<char>((src->
r + src->
g + src->
b)/3);
561 dest->
r =
static_cast<char>(src->
r);
562 dest->
g =
static_cast<char>(src->
g);
563 dest->
b =
static_cast<char>(src->
b);
568 *dest = ((src->
r + src->
g + src->
b)/3.0f);
573 dest->
r =
static_cast<float>(
static_cast<int>(src->
r));
574 dest->
g =
static_cast<float>(
static_cast<int>(src->
g));
575 dest->
b =
static_cast<float>(
static_cast<int>(src->
b));
580 dest->
r =
static_cast<unsigned char>(src->
r);
581 dest->
g =
static_cast<unsigned char>(src->
g);
582 dest->
b =
static_cast<unsigned char>(src->
b);
587 dest->
r =
static_cast<unsigned char>(src->
r);
588 dest->
g =
static_cast<unsigned char>(src->
g);
589 dest->
b =
static_cast<unsigned char>(src->
b);
594 dest->
r =
static_cast<unsigned char>(src->
r);
595 dest->
g =
static_cast<unsigned char>(src->
g);
596 dest->
b =
static_cast<unsigned char>(src->
b);
602 dest->
r =
static_cast<unsigned char>(src->
r);
603 dest->
g =
static_cast<unsigned char>(src->
g);
604 dest->
b =
static_cast<unsigned char>(src->
b);
699 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
709 *dest =
static_cast<int>((src->
r + src->
g + src->
b)/3);
719 *dest =
static_cast<char>((src->
r + src->
g + src->
b)/3);
761 *dest = ((src->
r + src->
g + src->
b)/3.0f);
780 *dest =
static_cast<unsigned char>(*src);
790 *dest =
static_cast<unsigned char>(*src);
795 *dest =
static_cast<char>(*src);
800 dest->
r =
static_cast<unsigned char>(*src);
801 dest->
g =
static_cast<unsigned char>(*src);
802 dest->
b =
static_cast<unsigned char>(*src);
807 dest->
r =
static_cast<unsigned char>(*src);
808 dest->
g =
static_cast<unsigned char>(*src);
809 dest->
b =
static_cast<unsigned char>(*src);
815 dest->
r =
static_cast<unsigned char>(*src);
816 dest->
g =
static_cast<unsigned char>(*src);
817 dest->
b =
static_cast<unsigned char>(*src);
823 dest->
r =
static_cast<int>(*src);
824 dest->
g =
static_cast<int>(*src);
825 dest->
b =
static_cast<int>(*src);
830 dest->
r =
static_cast<unsigned char>(*src);
831 dest->
g =
static_cast<unsigned char>(*src);
832 dest->
b =
static_cast<unsigned char>(*src);
837 dest->
v =
static_cast<unsigned char>(*src);
844 dest->
r =
static_cast<signed char>(*src);
845 dest->
g =
static_cast<signed char>(*src);
846 dest->
b =
static_cast<signed char>(*src);
867 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
872 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
887 *dest =
static_cast<char>((src->
r + src->
g + src->
b)/3);
892 dest->
r =
static_cast<unsigned char>(src->
r);
893 dest->
g =
static_cast<unsigned char>(src->
g);
894 dest->
b =
static_cast<unsigned char>(src->
b);
899 dest->
r =
static_cast<unsigned char>(src->
r);
900 dest->
g =
static_cast<unsigned char>(src->
g);
901 dest->
b =
static_cast<unsigned char>(src->
b);
907 dest->
r =
static_cast<unsigned char>(src->
r);
908 dest->
g =
static_cast<unsigned char>(src->
g);
909 dest->
b =
static_cast<unsigned char>(src->
b);
915 dest->
r =
static_cast<int>(src->
r);
916 dest->
g =
static_cast<int>(src->
g);
917 dest->
b =
static_cast<int>(src->
b);
922 dest->
r =
static_cast<unsigned char>(src->
r);
923 dest->
g =
static_cast<unsigned char>(src->
g);
924 dest->
b =
static_cast<unsigned char>(src->
b);
929 *dest = ((src->
r + src->
g + src->
b)/3);
934 dest->
r =
static_cast<signed char>(src->
r);
935 dest->
g =
static_cast<signed char>(src->
g);
936 dest->
b =
static_cast<signed char>(src->
b);
1015 dest->
r =
static_cast<char>(*src);
1016 dest->
g =
static_cast<char>(*src);
1017 dest->
b =
static_cast<char>(*src);
1022 dest->
r =
static_cast<char>(*src);
1023 dest->
g =
static_cast<char>(*src);
1024 dest->
b =
static_cast<char>(*src);
1030 dest->
r =
static_cast<char>(*src);
1031 dest->
g =
static_cast<char>(*src);
1032 dest->
b =
static_cast<char>(*src);
1045 dest->
r =
static_cast<char>(*src);
1046 dest->
g =
static_cast<char>(*src);
1047 dest->
b =
static_cast<char>(*src);
1053 dest->
h = dest->
s = 0;
1065 *dest =
static_cast<float>(*src);
1070 dest->
r =
static_cast<float>(*src);
1071 dest->
g =
static_cast<float>(*src);
1072 dest->
b =
static_cast<float>(*src);
1077 dest->
v = float(*src);
1084 *dest =
static_cast<char>(*src >> 1);
1101 dest->
r =
static_cast<char>(*src);
1102 dest->
g =
static_cast<char>(*src);
1103 dest->
b =
static_cast<char>(*src);
1108 dest->
r =
static_cast<char>(*src);
1109 dest->
g =
static_cast<char>(*src);
1110 dest->
b =
static_cast<char>(*src);
1116 dest->
r =
static_cast<char>(*src);
1117 dest->
g =
static_cast<char>(*src);
1118 dest->
b =
static_cast<char>(*src);
1124 dest->
r =
static_cast<int>(
static_cast<unsigned>(*src));
1125 dest->
g =
static_cast<int>(
static_cast<unsigned>(*src));
1126 dest->
b =
static_cast<int>(
static_cast<unsigned>(*src));
1131 *dest =
static_cast<int>(
static_cast<unsigned>(*src));
1136 dest->
r =
static_cast<char>(*src);
1137 dest->
g =
static_cast<char>(*src);
1138 dest->
b =
static_cast<char>(*src);
1157 *dest =
static_cast<float>(*src);
1162 dest->
r =
static_cast<float>(*src);
1163 dest->
g =
static_cast<float>(*src);
1164 dest->
b =
static_cast<float>(*src);
1169 dest->
v =
static_cast<float>(*src);
1176 *dest =
static_cast<char>(*src >> 1);
1200 template <
class T1,
class T2>
1201 static void CopyPixels(
const T1 *osrc,
int q1, T2 *odest,
int q2,
1205 const T1 *src = osrc;
1207 const int p1 =
PAD_BYTES (w *
sizeof(T1), q1);
1208 const int p2 =
PAD_BYTES (w *
sizeof(T2), q2);
1210 const int step2 = w*
sizeof(T2) + p2;
1211 DBG printf(
"q1 %d q2 %d (%dx%d) inc %d %d\n", q1, q2, w, h, p1, p2);
1214 odest =
reinterpret_cast<T2*
>(((
char *)odest) + step2*(h-1));
1218 for (
int i=0; i<h; i++) {
1219 DBG printf(
"x,y = %d,%d\n", 0,i);
1220 for (
int j = 0; j < w; j++) {
1226 src =
reinterpret_cast<const T1*
>(((
char *)src) + p1);
1227 odest =
reinterpret_cast<T2*
>(((
char *)odest) + step2*(flip?-1:1));
1248 #define HASH(id1, id2) ((int)(((int)(id1%65537))*11 + ((long int)(id2))))
1249 #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);
1250 #define MAKE_CASE(id1, id2) case HASH(id1, id2): HANDLE_CASE(len, src, Def_##id1, quantum1, topIsLow1, dest, Def_##id2, quantum2, topIsLow2); break;
1253 void Image::copyPixels(
const unsigned char *src,
size_t id1,
1254 char unsigned *dest,
size_t id2,
size_t w,
size_t h,
1255 size_t imageSize,
size_t quantum1,
size_t quantum2,
1256 bool topIsLow1,
bool topIsLow2)
1258 DBG printf(
"copyPixels...\n");
1260 if (id1==id2&&quantum1==quantum2&&topIsLow1==topIsLow2) {
1261 memcpy(dest,src,imageSize);
1266 switch(
HASH(id1,id2)) {
1488 printf(
"*** Tried to copy type %s to %s\n",
1495 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.