@@ -537,13 +537,15 @@ bool TiffDecoder::readData( Mat& img )
537537 }
538538 else
539539 {
540+ CV_CheckEQ (wanted_channels, 3 , " TIFF-8bpp: BGR/BGRA images are supported only" );
540541 icvCvt_BGRA2BGR_8u_C4C3R (bstart + i*tile_width0*4 , 0 ,
541542 img.ptr (img_y + tile_height - i - 1 , x), 0 ,
542543 Size (tile_width, 1 ), 2 );
543544 }
544545 }
545546 else
546547 {
548+ CV_CheckEQ (wanted_channels, 1 , " " );
547549 icvCvt_BGRA2Gray_8u_C4C1R ( bstart + i*tile_width0*4 , 0 ,
548550 img.ptr (img_y + tile_height - i - 1 , x), 0 ,
549551 Size (tile_width, 1 ), 2 );
@@ -569,12 +571,14 @@ bool TiffDecoder::readData( Mat& img )
569571 {
570572 if (ncn == 1 )
571573 {
574+ CV_CheckEQ (wanted_channels, 3 , " " );
572575 icvCvt_Gray2BGR_16u_C1C3R (buffer16 + i*tile_width0*ncn, 0 ,
573576 img.ptr <ushort>(img_y + i, x), 0 ,
574577 Size (tile_width, 1 ));
575578 }
576579 else if (ncn == 3 )
577580 {
581+ CV_CheckEQ (wanted_channels, 3 , " " );
578582 icvCvt_RGB2BGR_16u_C3R (buffer16 + i*tile_width0*ncn, 0 ,
579583 img.ptr <ushort>(img_y + i, x), 0 ,
580584 Size (tile_width, 1 ));
@@ -589,20 +593,20 @@ bool TiffDecoder::readData( Mat& img )
589593 }
590594 else
591595 {
596+ CV_CheckEQ (wanted_channels, 3 , " TIFF-16bpp: BGR/BGRA images are supported only" );
592597 icvCvt_BGRA2BGR_16u_C4C3R (buffer16 + i*tile_width0*ncn, 0 ,
593598 img.ptr <ushort>(img_y + i, x), 0 ,
594599 Size (tile_width, 1 ), 2 );
595600 }
596601 }
597602 else
598603 {
599- icvCvt_BGRA2BGR_16u_C4C3R (buffer16 + i*tile_width0*ncn, 0 ,
600- img.ptr <ushort>(img_y + i, x), 0 ,
601- Size (tile_width, 1 ), 2 );
604+ CV_Error (Error::StsError, " Not supported" );
602605 }
603606 }
604607 else
605608 {
609+ CV_CheckEQ (wanted_channels, 1 , " " );
606610 if ( ncn == 1 )
607611 {
608612 memcpy (img.ptr <ushort>(img_y + i, x),
0 commit comments