|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
22 template <
class T1,
class T2>
23 static inline void CopyPixel(
const T1 *src, T2 *dest)
119 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
129 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
141 *dest =
static_cast<char>((src->
r + src->
g + src->
b)/3);
176 *dest = ((src->
r + src->
g + src->
b)/3.0f);
297 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
307 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
317 *dest =
static_cast<char>((src->
r + src->
g + src->
b)/3);
329 *dest = ((src->
r + src->
g + src->
b)/3.0f);
378 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
388 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
398 *dest =
static_cast<char>((src->
r + src->
g + src->
b)/3);
410 *dest = ((src->
r + src->
g + src->
b)/3.0f);
458 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
468 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
478 *dest =
static_cast<char>((src->
r + src->
g + src->
b)/3);
490 *dest = ((src->
r + src->
g + src->
b)/3.0f);
538 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
548 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
558 *dest =
static_cast<char>((src->
r + src->
g + src->
b)/3);
563 dest->
r =
static_cast<char>(src->
r);
564 dest->
g =
static_cast<char>(src->
g);
565 dest->
b =
static_cast<char>(src->
b);
570 *dest = ((src->
r + src->
g + src->
b)/3.0f);
575 dest->
r =
static_cast<float>(
static_cast<int>(src->
r));
576 dest->
g =
static_cast<float>(
static_cast<int>(src->
g));
577 dest->
b =
static_cast<float>(
static_cast<int>(src->
b));
582 dest->
r =
static_cast<unsigned char>(src->
r);
583 dest->
g =
static_cast<unsigned char>(src->
g);
584 dest->
b =
static_cast<unsigned char>(src->
b);
589 dest->
r =
static_cast<unsigned char>(src->
r);
590 dest->
g =
static_cast<unsigned char>(src->
g);
591 dest->
b =
static_cast<unsigned char>(src->
b);
596 dest->
r =
static_cast<unsigned char>(src->
r);
597 dest->
g =
static_cast<unsigned char>(src->
g);
598 dest->
b =
static_cast<unsigned char>(src->
b);
604 dest->
r =
static_cast<unsigned char>(src->
r);
605 dest->
g =
static_cast<unsigned char>(src->
g);
606 dest->
b =
static_cast<unsigned char>(src->
b);
701 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
711 *dest =
static_cast<int>((src->
r + src->
g + src->
b)/3);
721 *dest =
static_cast<char>((src->
r + src->
g + src->
b)/3);
763 *dest = ((src->
r + src->
g + src->
b)/3.0f);
782 *dest =
static_cast<unsigned char>(*src);
792 *dest =
static_cast<unsigned char>(*src);
797 *dest =
static_cast<char>(*src);
802 dest->
r =
static_cast<unsigned char>(*src);
803 dest->
g =
static_cast<unsigned char>(*src);
804 dest->
b =
static_cast<unsigned char>(*src);
809 dest->
r =
static_cast<unsigned char>(*src);
810 dest->
g =
static_cast<unsigned char>(*src);
811 dest->
b =
static_cast<unsigned char>(*src);
817 dest->
r =
static_cast<unsigned char>(*src);
818 dest->
g =
static_cast<unsigned char>(*src);
819 dest->
b =
static_cast<unsigned char>(*src);
825 dest->
r =
static_cast<int>(*src);
826 dest->
g =
static_cast<int>(*src);
827 dest->
b =
static_cast<int>(*src);
832 dest->
r =
static_cast<unsigned char>(*src);
833 dest->
g =
static_cast<unsigned char>(*src);
834 dest->
b =
static_cast<unsigned char>(*src);
839 dest->
v =
static_cast<unsigned char>(*src);
846 dest->
r =
static_cast<signed char>(*src);
847 dest->
g =
static_cast<signed char>(*src);
848 dest->
b =
static_cast<signed char>(*src);
869 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
874 *dest =
static_cast<unsigned char>((src->
r + src->
g + src->
b)/3);
889 *dest =
static_cast<char>((src->
r + src->
g + src->
b)/3);
894 dest->
r =
static_cast<unsigned char>(src->
r);
895 dest->
g =
static_cast<unsigned char>(src->
g);
896 dest->
b =
static_cast<unsigned char>(src->
b);
901 dest->
r =
static_cast<unsigned char>(src->
r);
902 dest->
g =
static_cast<unsigned char>(src->
g);
903 dest->
b =
static_cast<unsigned char>(src->
b);
909 dest->
r =
static_cast<unsigned char>(src->
r);
910 dest->
g =
static_cast<unsigned char>(src->
g);
911 dest->
b =
static_cast<unsigned char>(src->
b);
917 dest->
r =
static_cast<int>(src->
r);
918 dest->
g =
static_cast<int>(src->
g);
919 dest->
b =
static_cast<int>(src->
b);
924 dest->
r =
static_cast<unsigned char>(src->
r);
925 dest->
g =
static_cast<unsigned char>(src->
g);
926 dest->
b =
static_cast<unsigned char>(src->
b);
931 *dest = ((src->
r + src->
g + src->
b)/3);
936 dest->
r =
static_cast<signed char>(src->
r);
937 dest->
g =
static_cast<signed char>(src->
g);
938 dest->
b =
static_cast<signed char>(src->
b);
1017 dest->
r =
static_cast<char>(*src);
1018 dest->
g =
static_cast<char>(*src);
1019 dest->
b =
static_cast<char>(*src);
1024 dest->
r =
static_cast<char>(*src);
1025 dest->
g =
static_cast<char>(*src);
1026 dest->
b =
static_cast<char>(*src);
1032 dest->
r =
static_cast<char>(*src);
1033 dest->
g =
static_cast<char>(*src);
1034 dest->
b =
static_cast<char>(*src);
1047 dest->
r =
static_cast<char>(*src);
1048 dest->
g =
static_cast<char>(*src);
1049 dest->
b =
static_cast<char>(*src);
1055 dest->
h = dest->
s = 0;
1067 *dest =
static_cast<float>(*src);
1072 dest->
r =
static_cast<float>(*src);
1073 dest->
g =
static_cast<float>(*src);
1074 dest->
b =
static_cast<float>(*src);
1079 dest->
v = float(*src);
1086 *dest =
static_cast<char>(*src >> 1);
1103 dest->
r =
static_cast<char>(*src);
1104 dest->
g =
static_cast<char>(*src);
1105 dest->
b =
static_cast<char>(*src);
1110 dest->
r =
static_cast<char>(*src);
1111 dest->
g =
static_cast<char>(*src);
1112 dest->
b =
static_cast<char>(*src);
1118 dest->
r =
static_cast<char>(*src);
1119 dest->
g =
static_cast<char>(*src);
1120 dest->
b =
static_cast<char>(*src);
1126 dest->
r =
static_cast<int>(
static_cast<unsigned>(*src));
1127 dest->
g =
static_cast<int>(
static_cast<unsigned>(*src));
1128 dest->
b =
static_cast<int>(
static_cast<unsigned>(*src));
1133 *dest =
static_cast<int>(
static_cast<unsigned>(*src));
1138 dest->
r =
static_cast<char>(*src);
1139 dest->
g =
static_cast<char>(*src);
1140 dest->
b =
static_cast<char>(*src);
1159 *dest =
static_cast<float>(*src);
1164 dest->
r =
static_cast<float>(*src);
1165 dest->
g =
static_cast<float>(*src);
1166 dest->
b =
static_cast<float>(*src);
1171 dest->
v =
static_cast<float>(*src);
1178 *dest =
static_cast<char>(*src >> 1);
1202 template <
class T1,
class T2>
1203 static void CopyPixels(
const T1 *osrc,
int q1, T2 *odest,
int q2,
1207 const T1 *src = osrc;
1209 const int p1 =
PAD_BYTES (w *
sizeof(T1), q1);
1210 const int p2 =
PAD_BYTES (w *
sizeof(T2), q2);
1212 const int step2 = w*
sizeof(T2) + p2;
1213 DBG printf(
"q1 %d q2 %d (%dx%d) inc %d %d\n", q1, q2, w, h, p1, p2);
1216 odest =
reinterpret_cast<T2*
>(((
char *)odest) + step2*(h-1));
1220 for (
int i=0; i<h; i++) {
1221 DBG printf(
"x,y = %d,%d\n", 0,i);
1222 for (
int j = 0; j < w; j++) {
1228 src =
reinterpret_cast<const T1*
>(((
char *)src) + p1);
1229 odest =
reinterpret_cast<T2*
>(((
char *)odest) + step2*(flip?-1:1));
1250 #define HASH(id1, id2) ((int)(((int)(id1%65537))*11 + ((long int)(id2))))
1251 #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);
1252 #define MAKE_CASE(id1, id2) case HASH(id1, id2): HANDLE_CASE(len, src, Def_##id1, quantum1, topIsLow1, dest, Def_##id2, quantum2, topIsLow2); break;
1255 void Image::copyPixels(
const unsigned char *src,
size_t id1,
1256 char unsigned *dest,
size_t id2,
size_t w,
size_t h,
1257 size_t imageSize,
size_t quantum1,
size_t quantum2,
1258 bool topIsLow1,
bool topIsLow2)
1260 DBG printf(
"copyPixels...\n");
1262 if (id1==id2&&quantum1==quantum2&&topIsLow1==topIsLow2) {
1263 memcpy(dest,src,imageSize);
1268 switch(
HASH(id1,id2)) {
1490 printf(
"*** Tried to copy type %zu to %zu\n", id1, id2);
1495 DBG printf(
"... done copyPixels\n");
PixelFloat Def_VOCAB_PIXEL_MONO_FLOAT
PixelMono16 Def_VOCAB_PIXEL_MONO16
PixelInt Def_VOCAB_PIXEL_INT
PixelMonoSigned Def_VOCAB_PIXEL_MONO_SIGNED
char PixelMonoSigned
Signed byte pixel type.
size_t PAD_BYTES(size_t len, size_t pad)
computes the padding of YARP images.
Packed RGB pixel type, with pixels stored in reverse order.
Signed, packed RGB pixel type.
Floating point HSV pixel type.
static void CopyPixel(const T1 *src, T2 *dest)
PixelMono Def_VOCAB_PIXEL_MONO
unsigned char PixelMono
Monochrome pixel type.
float PixelFloat
Floating point pixel type.
yarp::os::NetInt32 PixelInt
32-bit integer pixel type.
Packed HSV (hue/saturation/value pixel type.
@ VOCAB_PIXEL_MONO_SIGNED
#define MAKE_CASE(id1, id2)
static void CopyPixels(const T1 *osrc, int q1, T2 *odest, int q2, int w, int h, bool flip)
Floating point RGB pixel type.
yarp::os::NetUint16 PixelMono16
16-bit monochrome pixel type.