| 1302 | //------------------------------------------------------------------------------ |
| 1303 | template <typename T> |
| 1304 | int vtkTIFFReader::EvaluateImageAt(T* out, T* in) |
| 1305 | { |
| 1306 | unsigned char* image = reinterpret_cast<unsigned char*>(out); |
| 1307 | unsigned char* source = reinterpret_cast<unsigned char*>(in); |
| 1308 | unsigned short red, green, blue; |
| 1309 | switch (this->GetFormat()) |
| 1310 | { |
| 1311 | case vtkTIFFReader::GRAYSCALE: |
| 1312 | if (this->InternalImage->Photometrics == PHOTOMETRIC_MINISBLACK) |
| 1313 | { |
| 1314 | *out = *in; |
| 1315 | } |
| 1316 | else |
| 1317 | { |
| 1318 | *image = ~(*source); |
| 1319 | } |
| 1320 | return 1; |
| 1321 | case vtkTIFFReader::PALETTE_GRAYSCALE: |
| 1322 | if (this->IgnoreColorMap) |
| 1323 | { |
| 1324 | *out = *in; |
| 1325 | } |
| 1326 | else |
| 1327 | { |
| 1328 | this->GetColor(static_cast<int>(*in), &red, &green, &blue); |
| 1329 | *out = static_cast<T>(red); // red |
| 1330 | } |
| 1331 | return 1; |
| 1332 | case vtkTIFFReader::RGB: |
| 1333 | *(image) = *(source); // red |
| 1334 | *(image + 1) = *(source + 1); // green |
| 1335 | *(image + 2) = *(source + 2); // blue |
| 1336 | if (this->InternalImage->SamplesPerPixel == 4) |
| 1337 | { |
| 1338 | *(image + 3) = 255 - *(source + 3); // alpha |
| 1339 | } |
| 1340 | return this->InternalImage->SamplesPerPixel; |
| 1341 | case vtkTIFFReader::PALETTE_RGB: |
| 1342 | assert(!this->IgnoreColorMap); // if IgnoreColorMap, the format is set to PALETTE_GRAYSCALE. |
| 1343 | this->GetColor(static_cast<int>(*in), &red, &green, &blue); |
| 1344 | *(out) = red << 8; |
| 1345 | *(out + 1) = green << 8; |
| 1346 | *(out + 2) = blue << 8; |
| 1347 | if (this->GetDataScalarType() == VTK_SHORT || this->GetDataScalarType() == VTK_UNSIGNED_SHORT) |
| 1348 | { |
| 1349 | this->GetColor(static_cast<int>(*in), &red, &green, &blue); |
| 1350 | *(out) = red << 8; |
| 1351 | *(out + 1) = green << 8; |
| 1352 | *(out + 2) = blue << 8; |
| 1353 | } |
| 1354 | else |
| 1355 | { |
| 1356 | this->GetColor(static_cast<int>(*in), &red, &green, &blue); |
| 1357 | *(out) = red >> 8; |
| 1358 | *(out + 1) = green >> 8; |
| 1359 | *(out + 2) = blue >> 8; |
| 1360 | } |
| 1361 | return 3; |
no test coverage detected