10 #include "PlusConfigure.h" 16 #define FIX(a, b) ((int)((a)*(1<<(b)))) 17 #define UNFIX(a, b) ((a+(1<<(b-1)))>>(b)) 19 #define ICCIRUV(x) (((x)<<8)/224) 20 #define ICCIRY(x) ((((x)-16)<<8)/219) 22 #define CLIP(t) (((t)>255)?255:(((t)<0)?0:(t))) 23 #define GET_R_FROM_YUV(y, u, v) UNFIX((FIX(1.0, FIXNUM)*(y) + FIX(1.402, FIXNUM)*(v)), FIXNUM) 24 #define GET_G_FROM_YUV(y, u, v) UNFIX((FIX(1.0, FIXNUM)*(y) + FIX(-0.344, FIXNUM)*(u) + FIX(-0.714, FIXNUM)*(v)), FIXNUM) 25 #define GET_B_FROM_YUV(y, u, v) UNFIX((FIX(1.0, FIXNUM)*(y) + FIX(1.772, FIXNUM)*(u)), FIXNUM) 26 #define GET_Y_FROM_RGB(r, g, b) UNFIX((FIX(0.299, FIXNUM)*(r) + FIX(0.587, FIXNUM)*(g) + FIX(0.114, FIXNUM)*(b)), FIXNUM) 27 #define GET_U_FROM_RGB(r, g, b) UNFIX((FIX(-0.169, FIXNUM)*(r) + FIX(-0.331, FIXNUM)*(g) + FIX(0.500, FIXNUM)*(b)), FIXNUM) 28 #define GET_V_FROM_RGB(r, g, b) UNFIX((FIX(0.500, FIXNUM)*(r) + FIX(-0.419, FIXNUM)*(g) + FIX(-0.081, FIXNUM)*(b)), FIXNUM) 69 switch (inputCompression)
85 switch (inputCompression)
105 std::stringstream ss;
106 ss <<
"0x" << std::hex << std::setw(8) << std::setfill(
'0') << inputCompression;
107 std::string fourcc =
"????";
108 for (
int i = 0;
i < 4;
i++)
110 fourcc[
i] = (
unsigned char)(inputCompression >> (8 *
i)) & 0xff;
111 if (!isprint(fourcc[
i]))
116 return fourcc +
"(" + std::string(ss.str().c_str()) +
")";
122 switch (inputCompression)
140 LOG_ERROR(
"Unknown pixel format.");
148 switch (inputCompression)
162 LOG_ERROR(
"Unknown compression type: " << inputCompression);
171 switch (inputCompression)
187 LOG_ERROR(
"MJPG to grayscale conversion is not yet supported");
190 LOG_ERROR(
"Unknown compression type: " << inputCompression);
199 switch (inputCompression)
241 LOG_ERROR(
"Unknown compression type: " << inputCompression);
305 *d = ((
unsigned short)(s[0]) + s[1] + s[2]) / 3;
321 *d = ((
unsigned short)(s[0]) + s[1] + s[2]) / 3;
341 int Y = (yuv[0] - 16) * 76284;
342 int U = yuv[1] - 128;
343 int V = yuv[2] - 128;
345 int R = Y + 104595 *
V ;
346 int G = Y - 53281 *
V - 25625 * U;
347 int B = Y + 132252 * U;
360 if (
R < 0) {
R = 0; }
361 if (G < 0) { G = 0; }
362 if (B < 0) { B = 0; }
364 if (
R > 255) {
R = 255; };
365 if (G > 255) { G = 255; };
366 if (B > 255) { B = 255; };
377 LOG_ERROR(
"MJPEG is not supported yet");
389 unsigned char* p_dest;
390 unsigned char y1, u,
y2,
v;
392 unsigned char r, g,
b;
397 unsigned long srcIndex = 0;
398 unsigned long dstIndex = 0;
400 for (
int i = 0 ;
i < size ;
i++)
404 y2 = s[srcIndex + 2];
417 p_dest[dstIndex + 1] = g;
427 p_dest[dstIndex + 1] = g;
446 unsigned char* p_dest;
447 unsigned char y1, u,
y2,
v;
449 unsigned char r, g,
b;
454 unsigned long srcIndex = 0;
455 unsigned long dstIndex = 0;
457 for (
i = 0 ;
i < size ;
i++)
461 y2 = s[srcIndex + 2];
473 p_dest[dstIndex] = (
int(
b) + g + r) / 3;
480 p_dest[dstIndex] = (
int(
b) + g + r) / 3;
492 #endif //__PixelCodec_h static const long VTK_BI_YUY2
static void BGRA32ToRGB24(int width, int height, unsigned char *s, unsigned char *d)
static void RGBA32ToRGB24(int width, int height, unsigned char *s, unsigned char *d)
static const long VTK_BI_UYVY
Initial rotation matrix R
static PlusStatus ConvertToBGR24(ComponentOrdering outputOrdering, PixelEncoding inputCompression, int width, int height, unsigned char *s, unsigned char *d)
static bool IsConvertToGraySupported(int inputCompression)
static void RGBA32ToGray(int width, int height, unsigned char *s, unsigned char *d)
Initial rotation matrix b
static std::string GetCompressionModeAsString(int inputCompression)
static PlusStatus ConvertToGray(PixelEncoding inputCompression, int width, int height, unsigned char *s, unsigned char *d)
static void YUVToRGB_Fast(ComponentOrdering outputOrdering, unsigned char *yuv, unsigned char *rgb)
#define GET_R_FROM_YUV(y, u, v)
static std::string GetCompressionModeAsString(PixelEncoding inputCompression)
static void RGB24ToGray(int width, int height, unsigned char *s, unsigned char *d)
PhidgetLCD_Font int * width
#define GET_G_FROM_YUV(y, u, v)
static PlusStatus ConvertToGray(int inputCompression, int width, int height, unsigned char *s, unsigned char *d)
PhidgetLCD_Font int int * height
#define GET_B_FROM_YUV(y, u, v)
static void YUV422pToGray(int width, int height, unsigned char *s, unsigned char *d)
static bool IsConvertToGraySupported(PixelEncoding inputCompression)
static void RGBToBGR(int width, int height, unsigned char *s, unsigned char *d)
static PlusStatus MJPGToRGB24(ComponentOrdering outputOrdering, int width, int height, unsigned char *s, unsigned char *d)
static PlusStatus YUV422pToRGB24(ComponentOrdering outputOrdering, int width, int height, unsigned char *s, unsigned char *d)
static void RGBA32ToBGR24(int width, int height, unsigned char *s, unsigned char *d)
A utility class that contains static functions for converting between various pixel encodings.
Position vectors of rods v