53 #include <visp/vpImageConvert.h>
55 bool vpImageConvert::YCbCrLUTcomputed =
false;
56 int vpImageConvert::vpCrr[256];
57 int vpImageConvert::vpCgb[256];
58 int vpImageConvert::vpCgr[256];
59 int vpImageConvert::vpCbb[256];
105 for (
unsigned int i = 0; i < max_xy; i++) {
106 float val = 255.f * (src.
bitmap[i] - min) / (max - min);
112 dest.
bitmap[i] = (
unsigned char)val;
143 for (
unsigned int i = 0; i < max_xy; i++) {
144 double val = 255. * (src.
bitmap[i] - min) / (max - min);
150 dest.
bitmap[i] = (
unsigned char)val;
167 #ifdef VISP_HAVE_OPENCV
215 int nChannel = src->nChannels;
216 int depth = src->depth;
217 int height = src->height;
218 int width = src->width;
219 int widthStep = src->widthStep;
220 int lineStep = (flip) ? 1 : 0;
222 if(nChannel == 3 && depth == 8){
223 dest.
resize((
unsigned int)height, (
unsigned int)width);
226 unsigned char* input = (
unsigned char*)src->imageData;
228 unsigned char* beginOutput = (
unsigned char*)dest.
bitmap;
229 unsigned char* output = NULL;
231 for(
int i=0 ; i < height ; i++)
234 output = beginOutput + lineStep * ( 4 * width * ( height - 1 - i ) ) + (1-lineStep) * 4 * width * i;
235 for(
int j=0 ; j < width ; j++)
237 *(output++) = *(line+2);
238 *(output++) = *(line+1);
239 *(output++) = *(line);
248 else if(nChannel == 1 && depth == 8 ){
249 dest.
resize((
unsigned int)height, (
unsigned int)width);
251 unsigned char * input = (
unsigned char*)src->imageData;
252 unsigned char * line;
253 unsigned char* beginOutput = (
unsigned char*)dest.
bitmap;
254 unsigned char* output = NULL;
256 for(
int i=0 ; i < height ; i++)
259 output = beginOutput + lineStep * ( 4 * width * ( height - 1 - i ) ) + (1-lineStep) * 4 * width * i;
260 for(
int j=0 ; j < width ; j++)
265 *output++ = *(line);;
321 int nChannel = src->nChannels;
322 int depth = src->depth;
323 int height = src->height;
324 int width = src->width;
325 int widthStep = src->widthStep;
326 int lineStep = (flip) ? 1 : 0;
330 if(widthStep == width){
331 if(nChannel == 1 && depth == 8){
332 dest.
resize((
unsigned int)height, (
unsigned int)width) ;
333 memcpy(dest.
bitmap, src->imageData,
334 (
size_t)(height*width));
336 if(nChannel == 3 && depth == 8){
337 dest.
resize((
unsigned int)height, (
unsigned int)width) ;
338 BGRToGrey((
unsigned char*)src->imageData,dest.
bitmap, (
unsigned int)width, (
unsigned int)height,
false);
342 if(nChannel == 1 && depth == 8){
343 dest.
resize((
unsigned int)height, (
unsigned int)width) ;
344 for (
int i =0 ; i < height ; i++){
345 memcpy(dest.
bitmap+i*width, src->imageData + i*widthStep,
349 if(nChannel == 3 && depth == 8){
350 dest.
resize((
unsigned int)height, (
unsigned int)width) ;
351 for (
int i = 0 ; i < height ; i++){
352 BGRToGrey((
unsigned char*)src->imageData + i*widthStep,
353 dest.
bitmap + i*width, (
unsigned int)width, 1,
false);
360 if(nChannel == 1 && depth == 8){
361 dest.
resize((
unsigned int)height, (
unsigned int)width) ;
362 unsigned char* beginOutput = (
unsigned char*)dest.
bitmap;
363 for (
int i =0 ; i < height ; i++){
364 memcpy(beginOutput + lineStep * ( 4 * width * ( height - 1 - i ) ) , src->imageData + i*widthStep,
368 if(nChannel == 3 && depth == 8){
369 dest.
resize((
unsigned int)height, (
unsigned int)width) ;
371 BGRToGrey((
unsigned char*)src->imageData ,
372 dest.
bitmap , (
unsigned int)width, (
unsigned int)height,
true);
427 CvSize size = cvSize(width, height);
431 if(dest->nChannels != channels || dest->depth != depth
432 || dest->height != height || dest->width != width){
433 if(dest->nChannels != 0) cvReleaseImage(&dest);
434 dest = cvCreateImage( size, depth, channels );
437 else dest = cvCreateImage( size, depth, channels );
441 unsigned char * input = (
unsigned char*)src.
bitmap;
442 unsigned char * line;
443 unsigned char * output = (
unsigned char*)dest->imageData;
447 int widthStep = dest->widthStep;
449 for(i=0 ; i < height ; i++)
451 output = (
unsigned char*)dest->imageData + i*widthStep;
453 for( j=0 ; j < width ; j++)
455 *output++ = *(line+2);
456 *output++ = *(line+1);
514 unsigned int width = src.
getWidth();
515 CvSize size = cvSize((
int)width, (
int)height);
519 if(dest->nChannels != channels || dest->depth != depth
520 || dest->height != (
int) height || dest->width != (
int) width){
521 if(dest->nChannels != 0) cvReleaseImage(&dest);
522 dest = cvCreateImage( size, depth, channels );
525 else dest = cvCreateImage( size, depth, channels );
527 unsigned int widthStep = (
unsigned int)dest->widthStep;
529 if ( width == widthStep){
530 memcpy(dest->imageData,src.
bitmap, width*height);
534 for (
unsigned int i =0 ; i < height ; i++){
535 memcpy(dest->imageData + i*widthStep, src.
bitmap + i*width,
541 #if VISP_HAVE_OPENCV_VERSION >= 0x020100
587 if(src.type() == CV_8UC4){
588 dest.
resize((
unsigned int)src.rows, (
unsigned int)src.cols);
590 for(
unsigned int i=0; i<dest.
getRows(); ++i)
591 for(
unsigned int j=0; j<dest.
getCols(); ++j){
592 cv::Vec4b tmp = src.at<cv::Vec4b>((int)i, (
int)j);
598 dest[dest.
getRows()-i-1][j] = rgbaVal;
600 dest[i][j] = rgbaVal;
602 }
else if(src.type() == CV_8UC3){
603 dest.
resize((
unsigned int)src.rows, (
unsigned int)src.cols);
606 for(
unsigned int i=0; i<dest.
getRows(); ++i){
607 for(
unsigned int j=0; j<dest.
getCols(); ++j){
608 cv::Vec3b tmp = src.at<cv::Vec3b>((int)i, (
int)j);
613 dest[dest.
getRows()-i-1][j] = rgbaVal;
615 dest[i][j] = rgbaVal;
619 }
else if(src.type() == CV_8UC1){
620 dest.
resize((
unsigned int)src.rows, (
unsigned int)src.cols);
622 for(
unsigned int i=0; i<dest.
getRows(); ++i){
623 for(
unsigned int j=0; j<dest.
getCols(); ++j){
624 rgbaVal = src.at<
unsigned char>((int)i, (
int)j);
626 dest[dest.
getRows()-i-1][j] = rgbaVal;
628 dest[i][j] = rgbaVal;
680 if(src.type() == CV_8UC1){
681 dest.
resize((
unsigned int)src.rows, (
unsigned int)src.cols);
682 if(src.isContinuous() && !flip){
683 memcpy(dest.
bitmap, src.data, (
size_t)(src.rows*src.cols));
687 for(
unsigned int i=0; i<dest.
getRows(); ++i){
688 memcpy(dest.
bitmap+i*dest.
getCols(), src.data+(dest.
getRows()-i-1)*src.step1(), (size_t)src.step);
691 for(
unsigned int i=0; i<dest.
getRows(); ++i){
692 memcpy(dest.
bitmap+i*dest.
getCols(), src.data+i*src.step1(), (size_t)src.step);
696 }
else if(src.type() == CV_8UC3){
697 dest.
resize((
unsigned int)src.rows, (
unsigned int)src.cols);
698 if(src.isContinuous() && !flip){
699 BGRToGrey((
unsigned char*)src.data, (
unsigned char*)dest.
bitmap, (
unsigned int)src.cols, (
unsigned int)src.rows, flip);
703 for(
unsigned int i=0; i<dest.
getRows(); ++i){
704 BGRToGrey((
unsigned char*)src.data+i*src.step1(),
706 (
unsigned int)dest.
getCols(), 1,
false);
709 for(
unsigned int i=0; i<dest.
getRows(); ++i){
710 BGRToGrey((
unsigned char*)src.data+i*src.step1(),
712 (
unsigned int)dest.
getCols(), 1,
false);
767 cv::Mat out[] = {dest, alpha};
768 int from_to[] = { 0,2, 1,1, 2,0, 3,3 };
769 cv::mixChannels(&vpToMat, 1, out, 2, from_to, 4);
818 dest = tmpMap.clone();
827 #ifdef VISP_HAVE_YARP
861 yarp::sig::ImageOf< yarp::sig::PixelMono > *dest,
const bool copyData)
911 dest.
resize(src->height(),src->width());
913 memcpy(dest.
bitmap, src->getRawImage(), src->height()*src->width()*
sizeof(yarp::sig::PixelMono));
915 dest.
bitmap = src->getRawImage();
952 yarp::sig::ImageOf< yarp::sig::PixelRgba > *dest,
const bool copyData)
1002 dest.
resize(src->height(),src->width());
1004 memcpy(dest.
bitmap, src->getRawImage(),src->height()*src->width()*
sizeof(yarp::sig::PixelRgba));
1044 for(
unsigned int i = 0 ; i < src.
getRows() ; i++){
1045 for(
unsigned int j = 0 ; j < src.
getWidth() ; j++){
1046 dest->pixel(j,i).r = src[i][j].R;
1047 dest->pixel(j,i).g = src[i][j].G;
1048 dest->pixel(j,i).b = src[i][j].B;
1091 dest.
resize(src->height(),src->width());
1092 for(
int i = 0 ; i < src->height() ; i++){
1093 for(
int j = 0 ; j < src->width() ; j++){
1094 dest[i][j].R = src->pixel(j,i).r;
1095 dest[i][j].G = src->pixel(j,i).g;
1096 dest[i][j].B = src->pixel(j,i).b;
1104 #if defined(VISP_HAVE_LIBJPEG)
1105 #if JPEG_LIB_VERSION > 70
1115 unsigned char **dest,
long unsigned int &destSize,
int quality)
1117 struct jpeg_compress_struct cinfo;
1118 struct jpeg_error_mgr jerr;
1120 cinfo.err = jpeg_std_error(&jerr);
1121 jpeg_create_compress(&cinfo);
1126 jpeg_mem_dest(&cinfo, dest, &destSize);
1128 unsigned int width = src.
getWidth();
1131 cinfo.image_width = width;
1132 cinfo.image_height = height;
1133 cinfo.input_components = 1;
1134 cinfo.in_color_space = JCS_GRAYSCALE;
1135 jpeg_set_defaults(&cinfo);
1136 jpeg_set_quality(&cinfo, quality, TRUE);
1138 jpeg_start_compress(&cinfo,TRUE);
1140 unsigned char *line;
1141 line =
new unsigned char[width];
1142 unsigned char* input = (
unsigned char*)src.
bitmap;
1143 while (cinfo.next_scanline < cinfo.image_height)
1145 for (
unsigned int i = 0; i < width; i++)
1150 jpeg_write_scanlines(&cinfo, &line, 1);
1153 jpeg_finish_compress(&cinfo);
1154 jpeg_destroy_compress(&cinfo);
1165 void vpImageConvert::convertToJPEGBuffer(
unsigned char *src,
long unsigned int srcSize,
1168 struct jpeg_decompress_struct cinfo;
1169 struct jpeg_error_mgr jerr;
1171 cinfo.err = jpeg_std_error(&jerr);
1172 jpeg_create_decompress(&cinfo);
1174 jpeg_mem_src(&cinfo, src, srcSize);
1175 jpeg_read_header(&cinfo, TRUE);
1177 unsigned int width = cinfo.image_width;
1178 unsigned int height = cinfo.image_height;
1181 dest.
resize(height,width);
1183 jpeg_start_decompress(&cinfo);
1185 unsigned int rowbytes = cinfo.output_width * (
unsigned int)(cinfo.output_components);
1186 JSAMPARRAY buf = (*cinfo.mem->alloc_sarray) ((j_common_ptr) &cinfo, JPOOL_IMAGE, rowbytes, 1);
1188 if (cinfo.out_color_space == JCS_GRAYSCALE)
1191 while (cinfo.output_scanline<cinfo.output_height)
1193 row = cinfo.output_scanline;
1194 jpeg_read_scanlines(&cinfo,buf,1);
1195 memcpy(dest[row], buf[0], rowbytes);
1199 jpeg_finish_decompress(&cinfo);
1200 jpeg_destroy_decompress(&cinfo);
1203 #endif // defined(VISP_HAVE_LIBJPEG)
1207 if (c & (~255)) { if (c < 0) c = 0; else c = 255; }
1215 unsigned int width,
unsigned int height)
1220 int r, g, b, cr, cg, cb, y1, y2;
1230 cb = ((*s - 128) * 454) >> 8;
1231 cg = (*s++ - 128) * 88;
1233 cr = ((*s - 128) * 359) >> 8;
1234 cg = (cg + (*s++ - 128) * 183) >> 8;
1243 *d++ =
static_cast<unsigned char>(r);
1244 *d++ =
static_cast<unsigned char>(g);
1245 *d++ =
static_cast<unsigned char>(b);
1255 *d++ =
static_cast<unsigned char>(r);
1256 *d++ =
static_cast<unsigned char>(g);
1257 *d++ =
static_cast<unsigned char>(b);
1271 unsigned int width,
unsigned int height)
1276 int r, g, b, cr, cg, cb, y1, y2;
1286 cb = ((*s - 128) * 454) >> 8;
1287 cg = (*s++ - 128) * 88;
1289 cr = ((*s - 128) * 359) >> 8;
1290 cg = (cg + (*s++ - 128) * 183) >> 8;
1299 *d++ =
static_cast<unsigned char>(r);
1300 *d++ =
static_cast<unsigned char>(g);
1301 *d++ =
static_cast<unsigned char>(b);
1310 *d++ =
static_cast<unsigned char>(r);
1311 *d++ =
static_cast<unsigned char>(g);
1312 *d++ =
static_cast<unsigned char>(b);
1325 unsigned int i=0,j=0;
1329 grey[i++] = yuyv[j];
1330 grey[i++] = yuyv[j+2];
1346 register int U, V, R, G, B, V2, U5, UV;
1347 register int Y0, Y1, Y2, Y3;
1348 for(
unsigned int i = size / 4; i; i--) {
1349 U = (int)((*yuv++ - 128) * 0.354);
1353 V = (int)((*yuv++ - 128) * 0.707);
1364 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
1367 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
1370 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
1372 *rgba++ = (
unsigned char)R;
1373 *rgba++ = (
unsigned char)G;
1374 *rgba++ = (
unsigned char)B;
1379 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
1382 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
1385 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
1387 *rgba++ = (
unsigned char)R;
1388 *rgba++ = (
unsigned char)G;
1389 *rgba++ = (
unsigned char)B;
1394 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
1397 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
1400 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
1402 *rgba++ = (
unsigned char)R;
1403 *rgba++ = (
unsigned char)G;
1404 *rgba++ = (
unsigned char)B;
1409 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
1412 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
1415 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
1417 *rgba++ = (
unsigned char)R;
1418 *rgba++ = (
unsigned char)G;
1419 *rgba++ = (
unsigned char)B;
1424 unsigned int i=0,j=0;
1425 unsigned char r, g, b;
1426 while( j < numpixels*3/2)
1429 YUVToRGB (yuv[j+1], yuv[j], yuv[j+3], r, g, b);
1436 YUVToRGB (yuv[j+2], yuv[j], yuv[j+3], r, g, b);
1443 YUVToRGB (yuv[j+4], yuv[j], yuv[j+3], r, g, b);
1450 YUVToRGB (yuv[j+5], yuv[j], yuv[j+3], r, g, b);
1474 register int U, V, R, G, B, V2, U5, UV;
1475 register int Y0, Y1;
1476 for(
unsigned int i = size / 2; i; i-- ) {
1477 U = (int)((*yuv++ - 128) * 0.354);
1480 V = (int)((*yuv++ - 128) * 0.707);
1487 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
1490 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
1493 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
1495 *rgba++ = (
unsigned char)R;
1496 *rgba++ = (
unsigned char)G;
1497 *rgba++ = (
unsigned char)B;
1502 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
1505 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
1508 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
1510 *rgba++ = (
unsigned char)R;
1511 *rgba++ = (
unsigned char)G;
1512 *rgba++ = (
unsigned char)B;
1518 unsigned int i=0,j=0;
1519 unsigned char r, g, b;
1524 YUVToRGB (yuv[j+1], yuv[j], yuv[j+2], r, g, b);
1531 YUVToRGB (yuv[j+3], yuv[j], yuv[j+2], r, g, b);
1551 unsigned int i=0,j=0;
1552 while( j < size*3/2)
1555 grey[i ] = yuv[j+1];
1556 grey[i+1] = yuv[j+2];
1557 grey[i+2] = yuv[j+4];
1558 grey[i+3] = yuv[j+5];
1578 register int U, V, R, G, B, V2, U5, UV;
1579 register int Y0, Y1;
1580 for(
unsigned int i = size / 2; i; i-- ) {
1581 U = (int)((*yuv++ - 128) * 0.354);
1584 V = (int)((*yuv++ - 128) * 0.707);
1591 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
1594 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
1597 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
1599 *rgb++ = (
unsigned char)R;
1600 *rgb++ = (
unsigned char)G;
1601 *rgb++ = (
unsigned char)B;
1605 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
1608 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
1611 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
1613 *rgb++ = (
unsigned char)R;
1614 *rgb++ = (
unsigned char)G;
1615 *rgb++ = (
unsigned char)B;
1621 unsigned int i=0,j=0;
1622 unsigned char r, g, b;
1627 YUVToRGB (yuv[j+1], yuv[j], yuv[j+2], r, g, b);
1633 YUVToRGB (yuv[j+3], yuv[j], yuv[j+2], r, g, b);
1654 unsigned int i=0,j=0;
1658 grey[i++] = yuv[j+1];
1659 grey[i++] = yuv[j+3];
1674 register int U, V, R, G, B, V2, U5, UV;
1675 register int Y0, Y1, Y2, Y3;
1676 for(
unsigned int i = size / 4; i; i--) {
1677 U = (int)((*yuv++ - 128) * 0.354);
1681 V = (int)((*yuv++ - 128) * 0.707);
1692 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
1695 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
1698 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
1700 *rgb++ = (
unsigned char)R;
1701 *rgb++ = (
unsigned char)G;
1702 *rgb++ = (
unsigned char)B;
1706 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
1709 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
1712 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
1714 *rgb++ = (
unsigned char)R;
1715 *rgb++ = (
unsigned char)G;
1716 *rgb++ = (
unsigned char)B;
1720 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
1723 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
1726 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
1728 *rgb++ = (
unsigned char)R;
1729 *rgb++ = (
unsigned char)G;
1730 *rgb++ = (
unsigned char)B;
1734 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
1737 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
1740 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
1742 *rgb++ = (
unsigned char)R;
1743 *rgb++ = (
unsigned char)G;
1744 *rgb++ = (
unsigned char)B;
1749 unsigned int i=0,j=0;
1750 unsigned char r, g, b;
1752 while( j < size*3/2)
1754 YUVToRGB (yuv[j+1], yuv[j], yuv[j+3], r, g, b);
1760 YUVToRGB (yuv[j+2], yuv[j], yuv[j+3], r, g, b);
1766 YUVToRGB (yuv[j+4], yuv[j], yuv[j+3], r, g, b);
1772 YUVToRGB (yuv[j+5], yuv[j], yuv[j+3], r, g, b);
1794 unsigned int width,
unsigned int height)
1797 register int U, V, R, G, B, V2, U5, UV;
1798 register int Y0, Y1, Y2, Y3;
1799 unsigned int size = width*height;
1800 unsigned char* iU = yuv + size;
1801 unsigned char* iV = yuv + 5*size/4;
1802 for(
unsigned int i = 0; i<height/2; i++)
1804 for(
unsigned int j = 0; j < width/2 ; j++)
1806 U = (int)((*iU++ - 128) * 0.354);
1808 V = (int)((*iV++ - 128) * 0.707);
1823 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
1826 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
1829 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
1831 *rgba++ = (
unsigned char)R;
1832 *rgba++ = (
unsigned char)G;
1833 *rgba++ = (
unsigned char)B;
1838 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
1841 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
1844 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
1846 *rgba++ = (
unsigned char)R;
1847 *rgba++ = (
unsigned char)G;
1848 *rgba++ = (
unsigned char)B;
1850 rgba = rgba + 4*width-7;
1854 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
1857 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
1860 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
1862 *rgba++ = (
unsigned char)R;
1863 *rgba++ = (
unsigned char)G;
1864 *rgba++ = (
unsigned char)B;
1869 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
1872 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
1875 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
1877 *rgba++ = (
unsigned char)R;
1878 *rgba++ = (
unsigned char)G;
1879 *rgba++ = (
unsigned char)B;
1881 rgba = rgba -4*width+1;
1895 unsigned int width,
unsigned int height)
1898 register int U, V, R, G, B, V2, U5, UV;
1899 register int Y0, Y1, Y2, Y3;
1900 unsigned int size = width*height;
1901 unsigned char* iU = yuv + size;
1902 unsigned char* iV = yuv + 5*size/4;
1903 for(
unsigned int i = 0; i<height/2; i++)
1905 for(
unsigned int j = 0; j < width/2 ; j++)
1907 U = (int)((*iU++ - 128) * 0.354);
1909 V = (int)((*iV++ - 128) * 0.707);
1924 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
1927 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
1930 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
1932 *rgb++ = (
unsigned char)R;
1933 *rgb++ = (
unsigned char)G;
1934 *rgb++ = (
unsigned char)B;
1938 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
1941 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
1944 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
1946 *rgb++ = (
unsigned char)R;
1947 *rgb++ = (
unsigned char)G;
1948 *rgb = (
unsigned char)B;
1949 rgb = rgb + 3*width-5;
1953 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
1956 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
1959 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
1961 *rgb++ = (
unsigned char)R;
1962 *rgb++ = (
unsigned char)G;
1963 *rgb++ = (
unsigned char)B;
1967 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
1970 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
1973 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
1975 *rgb++ = (
unsigned char)R;
1976 *rgb++ = (
unsigned char)G;
1977 *rgb = (
unsigned char)B;
1978 rgb = rgb -3*width+1;
1993 for(
unsigned int i=0 ; i < size ; i++)
2007 register int U, V, R, G, B, V2, U5, UV;
2009 for(
unsigned int i = 0; i<size; i++)
2011 U = (int)((*yuv++ - 128) * 0.354);
2014 V = (int)((*yuv++ - 128) * 0.707);
2024 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2027 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2030 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2032 *rgba++ = (
unsigned char)R;
2033 *rgba++ = (
unsigned char)G;
2034 *rgba++ = (
unsigned char)B;
2046 register int U, V, R, G, B, V2, U5, UV;
2048 for(
unsigned int i = 0; i<size; i++)
2051 U = (int)((*yuv++ - 128) * 0.354);
2054 V = (int)((*yuv++ - 128) * 0.707);
2063 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2066 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2069 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2071 *rgb++ = (
unsigned char)R;
2072 *rgb++ = (
unsigned char)G;
2073 *rgb++ = (
unsigned char)B;
2086 for(
unsigned int i=0 ; i < size ; i++)
2100 unsigned int width,
unsigned int height)
2103 register int U, V, R, G, B, V2, U5, UV;
2104 register int Y0, Y1, Y2, Y3;
2105 unsigned int size = width*height;
2106 unsigned char* iV = yuv + size;
2107 unsigned char* iU = yuv + 5*size/4;
2108 for(
unsigned int i = 0; i<height/2; i++)
2110 for(
unsigned int j = 0; j < width/2 ; j++)
2112 U = (int)((*iU++ - 128) * 0.354);
2114 V = (int)((*iV++ - 128) * 0.707);
2129 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2132 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2135 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2137 *rgba++ = (
unsigned char)R;
2138 *rgba++ = (
unsigned char)G;
2139 *rgba++ = (
unsigned char)B;
2144 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2147 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2150 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2152 *rgba++ = (
unsigned char)R;
2153 *rgba++ = (
unsigned char)G;
2154 *rgba++ = (
unsigned char)B;
2156 rgba = rgba + 4*width-7;
2160 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2163 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2166 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2168 *rgba++ = (
unsigned char)R;
2169 *rgba++ = (
unsigned char)G;
2170 *rgba++ = (
unsigned char)B;
2175 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2178 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2181 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2183 *rgba++ = (
unsigned char)R;
2184 *rgba++ = (
unsigned char)G;
2185 *rgba++ = (
unsigned char)B;
2187 rgba = rgba -4*width+1;
2200 unsigned int height,
unsigned int width)
2203 register int U, V, R, G, B, V2, U5, UV;
2204 register int Y0, Y1, Y2, Y3;
2205 unsigned int size = width*height;
2206 unsigned char* iV = yuv + size;
2207 unsigned char* iU = yuv + 5*size/4;
2208 for(
unsigned int i = 0; i<height/2; i++)
2210 for(
unsigned int j = 0; j < width/2 ; j++)
2212 U = (int)((*iU++ - 128) * 0.354);
2214 V = (int)((*iV++ - 128) * 0.707);
2229 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2232 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2235 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2237 *rgb++ = (
unsigned char)R;
2238 *rgb++ = (
unsigned char)G;
2239 *rgb++ = (
unsigned char)B;
2243 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2246 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2249 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2251 *rgb++ = (
unsigned char)R;
2252 *rgb++ = (
unsigned char)G;
2253 *rgb = (
unsigned char)B;
2254 rgb = rgb + 3*width-5;
2258 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2261 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2264 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2266 *rgb++ = (
unsigned char)R;
2267 *rgb++ = (
unsigned char)G;
2268 *rgb++ = (
unsigned char)B;
2272 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2275 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2278 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2280 *rgb++ = (
unsigned char)R;
2281 *rgb++ = (
unsigned char)G;
2282 *rgb = (
unsigned char)B;
2283 rgb = rgb -3*width+1;
2297 unsigned int width,
unsigned int height)
2300 register int U, V, R, G, B, V2, U5, UV;
2301 register int Y0, Y1, Y2, Y3,Y4, Y5, Y6, Y7,Y8, Y9, Y10, Y11,Y12, Y13, Y14, Y15;
2302 unsigned int size = width*height;
2303 unsigned char* iV = yuv + size;
2304 unsigned char* iU = yuv + 17*size/16;
2305 for(
unsigned int i = 0; i<height/4; i++)
2307 for(
unsigned int j = 0; j < width/4 ; j++)
2309 U = (int)((*iU++ - 128) * 0.354);
2311 V = (int)((*iV++ - 128) * 0.707);
2333 yuv = yuv-3*width+1;
2340 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2343 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2346 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2348 *rgba++ = (
unsigned char)R;
2349 *rgba++ = (
unsigned char)G;
2350 *rgba++ = (
unsigned char)B;
2355 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2358 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2361 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2363 *rgba++ = (
unsigned char)R;
2364 *rgba++ = (
unsigned char)G;
2365 *rgba++ = (
unsigned char)B;
2370 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2373 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2376 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2378 *rgba++ = (
unsigned char)R;
2379 *rgba++ = (
unsigned char)G;
2380 *rgba++ = (
unsigned char)B;
2385 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2388 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2391 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2393 *rgba++ = (
unsigned char)R;
2394 *rgba++ = (
unsigned char)G;
2395 *rgba++ = (
unsigned char)B;
2397 rgba = rgba + 4*width-15;
2400 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2403 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2406 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2408 *rgba++ = (
unsigned char)R;
2409 *rgba++ = (
unsigned char)G;
2410 *rgba++ = (
unsigned char)B;
2415 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2418 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2421 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2423 *rgba++ = (
unsigned char)R;
2424 *rgba++ = (
unsigned char)G;
2425 *rgba++ = (
unsigned char)B;
2430 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2433 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2436 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2438 *rgba++ = (
unsigned char)R;
2439 *rgba++ = (
unsigned char)G;
2440 *rgba++ = (
unsigned char)B;
2445 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2448 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2451 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2453 *rgba++ = (
unsigned char)R;
2454 *rgba++ = (
unsigned char)G;
2455 *rgba++ = (
unsigned char)B;
2457 rgba = rgba + 4*width-15;
2460 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2463 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2466 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2468 *rgba++ = (
unsigned char)R;
2469 *rgba++ = (
unsigned char)G;
2470 *rgba++ = (
unsigned char)B;
2475 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2478 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2481 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2483 *rgba++ = (
unsigned char)R;
2484 *rgba++ = (
unsigned char)G;
2485 *rgba++ = (
unsigned char)B;
2490 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2493 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2496 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2498 *rgba++ = (
unsigned char)R;
2499 *rgba++ = (
unsigned char)G;
2500 *rgba++ = (
unsigned char)B;
2505 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2508 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2511 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2513 *rgba++ = (
unsigned char)R;
2514 *rgba++ = (
unsigned char)G;
2515 *rgba++ = (
unsigned char)B;
2517 rgba = rgba + 4*width-15;
2520 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2523 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2526 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2528 *rgba++ = (
unsigned char)R;
2529 *rgba++ = (
unsigned char)G;
2530 *rgba++ = (
unsigned char)B;
2535 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2538 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2541 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2543 *rgba++ = (
unsigned char)R;
2544 *rgba++ = (
unsigned char)G;
2545 *rgba++ = (
unsigned char)B;
2550 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2553 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2556 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2558 *rgba++ = (
unsigned char)R;
2559 *rgba++ = (
unsigned char)G;
2560 *rgba++ = (
unsigned char)B;
2565 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2568 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2571 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2573 *rgba++ = (
unsigned char)R;
2574 *rgba++ = (
unsigned char)G;
2575 *rgba++ = (
unsigned char)B;
2577 rgba = rgba -12*width+1;
2590 unsigned int height,
unsigned int width)
2593 register int U, V, R, G, B, V2, U5, UV;
2594 register int Y0, Y1, Y2, Y3, Y4, Y5, Y6, Y7, Y8, Y9, Y10, Y11, Y12, Y13, Y14, Y15;
2595 unsigned int size = width*height;
2596 unsigned char* iV = yuv + size;
2597 unsigned char* iU = yuv + 17*size/16;
2598 for(
unsigned int i = 0; i<height/4; i++)
2600 for(
unsigned int j = 0; j < width/4 ; j++)
2602 U = (int)((*iU++ - 128) * 0.354);
2604 V = (int)((*iV++ - 128) * 0.707);
2626 yuv = yuv-3*width+1;
2633 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2636 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2639 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2641 *rgb++ = (
unsigned char)R;
2642 *rgb++ = (
unsigned char)G;
2643 *rgb++ = (
unsigned char)B;
2647 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2650 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2653 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2655 *rgb++ = (
unsigned char)R;
2656 *rgb++ = (
unsigned char)G;
2657 *rgb++ = (
unsigned char)B;
2661 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2664 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2667 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2669 *rgb++ = (
unsigned char)R;
2670 *rgb++ = (
unsigned char)G;
2671 *rgb++ = (
unsigned char)B;
2675 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2678 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2681 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2683 *rgb++ = (
unsigned char)R;
2684 *rgb++ = (
unsigned char)G;
2685 *rgb = (
unsigned char)B;
2686 rgb = rgb + 3*width-11;
2689 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2692 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2695 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2697 *rgb++ = (
unsigned char)R;
2698 *rgb++ = (
unsigned char)G;
2699 *rgb++ = (
unsigned char)B;
2703 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2706 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2709 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2711 *rgb++ = (
unsigned char)R;
2712 *rgb++ = (
unsigned char)G;
2713 *rgb++ = (
unsigned char)B;
2717 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2720 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2723 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2725 *rgb++ = (
unsigned char)R;
2726 *rgb++ = (
unsigned char)G;
2727 *rgb++ = (
unsigned char)B;
2731 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2734 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2737 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2739 *rgb++ = (
unsigned char)R;
2740 *rgb++ = (
unsigned char)G;
2741 *rgb = (
unsigned char)B;
2742 rgb = rgb + 3*width-11;
2745 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2748 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2751 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2753 *rgb++ = (
unsigned char)R;
2754 *rgb++ = (
unsigned char)G;
2755 *rgb++ = (
unsigned char)B;
2759 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2762 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2765 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2767 *rgb++ = (
unsigned char)R;
2768 *rgb++ = (
unsigned char)G;
2769 *rgb++ = (
unsigned char)B;
2773 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2776 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2779 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2781 *rgb++ = (
unsigned char)R;
2782 *rgb++ = (
unsigned char)G;
2783 *rgb++ = (
unsigned char)B;
2787 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2790 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2793 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2795 *rgb++ = (
unsigned char)R;
2796 *rgb++ = (
unsigned char)G;
2797 *rgb = (
unsigned char)B;
2798 rgb = rgb + 3*width-11;
2801 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2804 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2807 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2809 *rgb++ = (
unsigned char)R;
2810 *rgb++ = (
unsigned char)G;
2811 *rgb++ = (
unsigned char)B;
2815 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2818 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2821 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2823 *rgb++ = (
unsigned char)R;
2824 *rgb++ = (
unsigned char)G;
2825 *rgb++ = (
unsigned char)B;
2829 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2832 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2835 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2837 *rgb++ = (
unsigned char)R;
2838 *rgb++ = (
unsigned char)G;
2839 *rgb++ = (
unsigned char)B;
2843 if ((R >> 8) > 0) R = 255;
else if (R < 0) R = 0;
2846 if ((G >> 8) > 0) G = 255;
else if (G < 0) G = 0;
2849 if ((B >> 8) > 0) B = 255;
else if (B < 0) B = 0;
2851 *rgb++ = (
unsigned char)R;
2852 *rgb++ = (
unsigned char)G;
2853 *rgb++ = (
unsigned char)B;
2854 rgb = rgb -9*width+1;
2868 unsigned char *pt_input = rgb;
2869 unsigned char *pt_end = rgb + 3*size;
2870 unsigned char *pt_output = rgba;
2872 while(pt_input != pt_end) {
2873 *(pt_output++) = *(pt_input++) ;
2874 *(pt_output++) = *(pt_input++) ;
2875 *(pt_output++) = *(pt_input++) ;
2876 *(pt_output++) = 0 ;
2887 unsigned char *pt_input = rgba;
2888 unsigned char *pt_end = rgba + 4*size;
2889 unsigned char *pt_output = rgb;
2891 while(pt_input != pt_end) {
2892 *(pt_output++) = *(pt_input++) ;
2893 *(pt_output++) = *(pt_input++) ;
2894 *(pt_output++) = *(pt_input++) ;
2906 unsigned char *pt_input = rgb;
2907 unsigned char* pt_end = rgb + size*3;
2908 unsigned char *pt_output = grey;
2909 while(pt_input != pt_end) {
2910 *pt_output = (
unsigned char) (0.2126 * (*pt_input)
2911 + 0.7152 * (*(pt_input + 1))
2912 + 0.0722 * (*(pt_input + 2)) );
2926 unsigned char *pt_input = rgba;
2927 unsigned char* pt_end = rgba + size*4;
2928 unsigned char *pt_output = grey;
2930 while(pt_input != pt_end) {
2931 *pt_output = (
unsigned char) (0.2126 * (*pt_input)
2932 + 0.7152 * (*(pt_input + 1))
2933 + 0.0722 * (*(pt_input + 2)) );
2946 unsigned char *pt_input = grey;
2947 unsigned char *pt_end = grey + size;
2948 unsigned char *pt_output = rgba;
2950 while(pt_input != pt_end) {
2951 unsigned char p = *pt_input ;
2953 *(pt_output + 1) = p ;
2954 *(pt_output + 2) = p ;
2955 *(pt_output + 3) = p ;
2969 unsigned char *pt_input = grey;
2970 unsigned char* pt_end = grey + size;
2971 unsigned char *pt_output = rgb;
2973 while(pt_input != pt_end) {
2974 unsigned char p = *pt_input ;
2976 *(pt_output + 1) = p ;
2977 *(pt_output + 2) = p ;
2992 unsigned int width,
unsigned int height,
bool flip)
2996 int lineStep = (flip) ? -(
int)(width*3) : (
int)(width*3);
2999 unsigned char * src = (flip) ? (bgr+(width*height*3)+lineStep) : bgr;
3000 unsigned char * line;
3005 for(i=0 ; i < height ; i++)
3008 for( j=0 ; j < width ; j++)
3010 *rgba++ = *(line+2);
3011 *rgba++ = *(line+1);
3012 *rgba++ = *(line+0);
3030 unsigned int width,
unsigned int height,
bool flip)
3034 int lineStep = (flip) ? -(
int)(width*3) : (
int)(width*3);
3037 unsigned char * src = (flip) ? bgr+(width*height*3)+lineStep : bgr;
3038 unsigned char * line;
3043 for(i=0 ; i < height ; i++)
3046 for( j=0 ; j < width ; j++)
3048 *grey++ = (
unsigned char)( 0.2126 * *(line+2)
3049 + 0.7152 * *(line+1)
3050 + 0.0722 * *(line+0)) ;
3065 unsigned int width,
unsigned int height,
bool flip)
3069 int lineStep = (flip) ? -(
int)(width*3) : (
int)(width*3);
3072 unsigned char * src = (flip) ? (rgb+(width*height*3)+lineStep) : rgb;
3073 unsigned char * line;
3078 for(i=0 ; i < height ; i++)
3081 for( j=0 ; j < width ; j++)
3083 *rgba++ = *(line++);
3084 *rgba++ = *(line++);
3085 *rgba++ = *(line++);
3100 unsigned int width,
unsigned int height,
bool flip)
3104 int lineStep = (flip) ? -(
int)(width*3) : (
int)(width*3);
3107 unsigned char * src = (flip) ? rgb+(width*height*3)+lineStep : rgb;
3108 unsigned char * line;
3115 for(i=0 ; i < height ; i++)
3118 for( j=0 ; j < width ; j++)
3123 *grey++ = (
unsigned char)( 0.2126 * r + 0.7152 * g + 0.0722 * b) ;
3136 void vpImageConvert::computeYCbCrLUT()
3138 if (YCbCrLUTcomputed ==
false) {
3139 int index = 256, aux;
3144 vpImageConvert::vpCrr[index] = (int)( 364.6610 * aux) >> 8;
3145 vpImageConvert::vpCgb[index] = (int)( -89.8779 * aux) >> 8;
3146 vpImageConvert::vpCgr[index] = (int)(-185.8154 * aux) >> 8;
3147 vpImageConvert::vpCbb[index] = (int)( 460.5724 * aux) >> 8;
3150 YCbCrLUTcomputed =
true;
3178 unsigned char *pt_ycbcr = ycbcr;
3179 unsigned char *pt_rgb = rgb;
3183 vpImageConvert::computeYCbCrLUT();
3188 register int val_r, val_g, val_b;
3194 val_r = *pt_ycbcr + vpImageConvert::vpCrr[*crv];
3195 val_g = *pt_ycbcr + vpImageConvert::vpCgb[*cbv] + vpImageConvert::vpCgr[*crv];
3196 val_b = *pt_ycbcr + vpImageConvert::vpCbb[*cbv];
3198 vpDEBUG_TRACE(5,
"[%d] R: %d G: %d B: %d\n", size, val_r, val_g, val_b);
3200 *pt_rgb++ = (val_r < 0) ? 0u :
3201 ((val_r > 255) ? 255u : (
unsigned char)val_r);
3202 *pt_rgb++ = (val_g < 0) ? 0u :
3203 ((val_g > 255) ? 255u : (
unsigned char)val_g);
3204 *pt_rgb++ = (val_b < 0) ? 0u :
3205 ((val_b > 255) ? 255u : (
unsigned char)val_b);
3236 unsigned char *pt_ycbcr = ycbcr;
3237 unsigned char *pt_rgba = rgba;
3241 vpImageConvert::computeYCbCrLUT();
3246 register int val_r, val_g, val_b;
3252 val_r = *pt_ycbcr + vpImageConvert::vpCrr[*crv];
3253 val_g = *pt_ycbcr + vpImageConvert::vpCgb[*cbv] + vpImageConvert::vpCgr[*crv];
3254 val_b = *pt_ycbcr + vpImageConvert::vpCbb[*cbv];
3256 vpDEBUG_TRACE(5,
"[%d] R: %d G: %d B: %d\n", size, val_r, val_g, val_b);
3258 *pt_rgba++ = (val_r < 0) ? 0u :
3259 ((val_r > 255) ? 255u : (
unsigned char)val_r);
3260 *pt_rgba++ = (val_g < 0) ? 0u :
3261 ((val_g > 255) ? 255u : (
unsigned char)val_g);
3262 *pt_rgba++ = (val_b < 0) ? 0u :
3263 ((val_b > 255) ? 255u : (
unsigned char)val_b);
3289 unsigned int i=0,j=0;
3294 grey[i++] = yuv[j+2];
3321 unsigned char *pt_ycbcr = ycrcb;
3322 unsigned char *pt_rgb = rgb;
3326 vpImageConvert::computeYCbCrLUT();
3331 register int val_r, val_g, val_b;
3337 val_r = *pt_ycbcr + vpImageConvert::vpCrr[*crv];
3338 val_g = *pt_ycbcr + vpImageConvert::vpCgb[*cbv] + vpImageConvert::vpCgr[*crv];
3339 val_b = *pt_ycbcr + vpImageConvert::vpCbb[*cbv];
3341 vpDEBUG_TRACE(5,
"[%d] R: %d G: %d B: %d\n", size, val_r, val_g, val_b);
3343 *pt_rgb++ = (val_r < 0) ? 0u :
3344 ((val_r > 255) ? 255u : (
unsigned char)val_r);
3345 *pt_rgb++ = (val_g < 0) ? 0u :
3346 ((val_g > 255) ? 255u : (
unsigned char)val_g);
3347 *pt_rgb++ = (val_b < 0) ? 0u :
3348 ((val_b > 255) ? 255u : (
unsigned char)val_b);
3377 unsigned char *pt_ycbcr = ycrcb;
3378 unsigned char *pt_rgba = rgba;
3382 vpImageConvert::computeYCbCrLUT();
3387 register int val_r, val_g, val_b;
3393 val_r = *pt_ycbcr + vpImageConvert::vpCrr[*crv];
3394 val_g = *pt_ycbcr + vpImageConvert::vpCgb[*cbv] + vpImageConvert::vpCgr[*crv];
3395 val_b = *pt_ycbcr + vpImageConvert::vpCbb[*cbv];
3397 vpDEBUG_TRACE(5,
"[%d] R: %d G: %d B: %d\n", size, val_r, val_g, val_b);
3399 *pt_rgba++ = (val_r < 0) ? 0u :
3400 ((val_r > 255) ? 255u : (
unsigned char)val_r);
3401 *pt_rgba++ = (val_g < 0) ? 0u :
3402 ((val_g > 255) ? 255u : (
unsigned char)val_g);
3403 *pt_rgba++ = (val_b < 0) ? 0u :
3404 ((val_b > 255) ? 255u : (
unsigned char)val_b);
3454 unsigned int width = src.
getWidth();
3455 unsigned char* input;
3456 unsigned char* dst ;
3472 for(
unsigned int j = 0;j < 4;j++){
3473 if(tabChannel[j]!=NULL){
3474 if(tabChannel[j]->getHeight() != height ||
3475 tabChannel[j]->getWidth() != width){
3476 tabChannel[j]->
resize(height,width);
3478 dst = (
unsigned char*)tabChannel[j]->bitmap;
3480 input = (
unsigned char*)src.
bitmap+j;
3485 for (; i < n; i += 4) {
3486 *dst = *input; input += 4; dst++;
3487 *dst = *input; input += 4; dst++;
3488 *dst = *input; input += 4; dst++;
3489 *dst = *input; input += 4; dst++;
3494 for (; i < n; i++) {
3495 *dst = *input; input += 4; dst ++;
3513 register int i = (((int)size)<<1)-1;
3514 register int j = (int)size-1;
3519 grey[j--] =
static_cast<unsigned char>( (y+(grey16[i--]<<8))>>8 );
3535 register int i = (((int)size)<<1)-1;
3536 register int j = (int)(size*4-1);
3538 register unsigned char v;
3542 v =
static_cast<unsigned char>( (y+(grey16[i--]<<8))>>8 );
unsigned int getCols() const
static void BGRToRGBa(unsigned char *bgr, unsigned char *rgba, unsigned int width, unsigned int height, bool flip=false)
static void YUYVToRGBa(unsigned char *yuyv, unsigned char *rgba, unsigned int width, unsigned int height)
static void RGBToGrey(unsigned char *rgb, unsigned char *grey, unsigned int size)
unsigned int getWidth() const
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
void getMinMaxValue(Type &min, Type &max) const
Look for the minimum and the maximum value within the bitmap.
unsigned char B
Blue component.
static void RGBToRGBa(unsigned char *rgb, unsigned char *rgba, unsigned int size)
static void BGRToGrey(unsigned char *bgr, unsigned char *grey, unsigned int width, unsigned int height, bool flip=false)
Type * bitmap
points toward the bitmap
static void MONO16ToGrey(unsigned char *grey16, unsigned char *grey, unsigned int size)
static void YUV422ToRGB(unsigned char *yuv, unsigned char *rgb, unsigned int size)
static void YUV420ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
static void GreyToRGBa(unsigned char *grey, unsigned char *rgba, unsigned int size)
static void YUV422ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
static void YCbCrToRGB(unsigned char *ycbcr, unsigned char *rgb, unsigned int size)
static void YUV411ToRGB(unsigned char *yuv, unsigned char *rgb, unsigned int size)
static void split(const vpImage< vpRGBa > &src, vpImage< unsigned char > *pR, vpImage< unsigned char > *pG, vpImage< unsigned char > *pB, vpImage< unsigned char > *pa=NULL)
static void YUVToRGB(unsigned char y, unsigned char u, unsigned char v, unsigned char &r, unsigned char &g, unsigned char &b)
unsigned char G
Green component.
static void GreyToRGB(unsigned char *grey, unsigned char *rgb, unsigned int size)
Class that defines a RGB 32 bits structure.
static void YUV444ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
static void YUV420ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int width, unsigned int height)
static void YVU9ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int width, unsigned int height)
static void YUV422ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
unsigned int getRows() const
static void YVU9ToRGB(unsigned char *yuv, unsigned char *rgb, unsigned int width, unsigned int height)
static void YV12ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int width, unsigned int height)
static void YCbCrToGrey(unsigned char *ycbcr, unsigned char *grey, unsigned int size)
unsigned char A
Additionnal component.
static void YUYVToGrey(unsigned char *yuyv, unsigned char *grey, unsigned int size)
static void MONO16ToRGBa(unsigned char *grey16, unsigned char *rgba, unsigned int size)
unsigned int getNumberOfPixel() const
void resize(const unsigned int h, const unsigned int w)
set the size of the image without initializing it.
static void YUYVToRGB(unsigned char *yuyv, unsigned char *rgb, unsigned int width, unsigned int height)
static void YUV444ToRGB(unsigned char *yuv, unsigned char *rgb, unsigned int size)
static void YUV444ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
static void YUV411ToRGBa(unsigned char *yuv, unsigned char *rgba, unsigned int size)
unsigned char R
Red component.
unsigned int getHeight() const
static void YCbCrToRGBa(unsigned char *ycbcr, unsigned char *rgb, unsigned int size)
static void YUV411ToGrey(unsigned char *yuv, unsigned char *grey, unsigned int size)
static void RGBaToRGB(unsigned char *rgba, unsigned char *rgb, unsigned int size)
static void YCrCbToRGB(unsigned char *ycbcr, unsigned char *rgb, unsigned int size)
static void YCrCbToRGBa(unsigned char *ycbcr, unsigned char *rgb, unsigned int size)
static void RGBaToGrey(unsigned char *rgba, unsigned char *grey, unsigned int size)
static void YV12ToRGB(unsigned char *yuv, unsigned char *rgb, unsigned int width, unsigned int height)
static void YUV420ToRGB(unsigned char *yuv, unsigned char *rgb, unsigned int width, unsigned int height)