MCPcopy Create free account
hub / github.com/Kitware/VTK / ReadTwoSamplesPerPixelImage

Method ReadTwoSamplesPerPixelImage

IO/Image/vtkTIFFReader.cxx:971–1112  ·  view source on GitHub ↗

To Support Zeiss images that contains only 2 samples per pixel but are actually * RGB images */

Source from the content-addressed store, hash-verified

969/** To Support Zeiss images that contains only 2 samples per pixel but are actually
970 * RGB images */
971void vtkTIFFReader::ReadTwoSamplesPerPixelImage(void* out, unsigned int width, unsigned int height)
972{
973 unsigned int isize = TIFFScanlineSize(this->InternalImage->Image);
974 unsigned int cc;
975 int row;
976 tdata_t buf = _TIFFmalloc(isize);
977
978 int inc = 1;
979
980 if (this->GetDataScalarType() == VTK_UNSIGNED_CHAR)
981 {
982 unsigned char* image;
983 if (this->InternalImage->PlanarConfig == PLANARCONFIG_CONTIG)
984 {
985 for (row = 0; row < (int)height; row++)
986 {
987 if (TIFFReadScanline(this->InternalImage->Image, buf, row, 0) <= 0)
988 {
989 vtkErrorMacro(<< "Problem reading the row: " << row);
990 break;
991 }
992
993 if (this->InternalImage->Orientation == ORIENTATION_TOPLEFT)
994 {
995 image = reinterpret_cast<unsigned char*>(out) + row * width * inc;
996 }
997 else
998 {
999 image = reinterpret_cast<unsigned char*>(out) + width * inc * (height - (row + 1));
1000 }
1001
1002 for (cc = 0; cc < isize; cc += this->InternalImage->SamplesPerPixel)
1003 {
1004 inc = this->EvaluateImageAt(image, static_cast<unsigned char*>(buf) + cc);
1005 image += inc;
1006 }
1007 }
1008 }
1009 else if (this->InternalImage->PlanarConfig == PLANARCONFIG_SEPARATE)
1010 {
1011 unsigned long s;
1012 unsigned long nsamples = 0;
1013 TIFFGetField(this->InternalImage->Image, TIFFTAG_SAMPLESPERPIXEL, &nsamples);
1014 for (s = 0; s < nsamples; s++)
1015 {
1016 for (row = 0; row < (int)height; row++)
1017 {
1018 if (TIFFReadScanline(this->InternalImage->Image, buf, row, s) <= 0)
1019 {
1020 vtkErrorMacro(<< "Problem reading the row: " << row);
1021 break;
1022 }
1023
1024 inc = 3;
1025
1026 if (this->InternalImage->Orientation == ORIENTATION_TOPLEFT)
1027 {
1028 image = reinterpret_cast<unsigned char*>(out) + row * width * inc;

Callers 1

ReadVolumeMethod · 0.95

Calls 7

EvaluateImageAtMethod · 0.95
TIFFScanlineSizeFunction · 0.85
TIFFReadScanlineFunction · 0.85
TIFFGetFieldFunction · 0.85
GetDataScalarTypeMethod · 0.80
_TIFFmallocFunction · 0.50
_TIFFfreeFunction · 0.50

Tested by

no test coverage detected