| 1483 | // and unsigned short. |
| 1484 | template <class T> |
| 1485 | void vtkColorTransferFunctionMapData(vtkColorTransferFunction* self, T* input, |
| 1486 | unsigned char* output, int length, int inIncr, int outFormat, long) |
| 1487 | { |
| 1488 | double x; |
| 1489 | int i = length; |
| 1490 | double rgb[3]; |
| 1491 | unsigned char* optr = output; |
| 1492 | T* iptr = input; |
| 1493 | unsigned char alpha = static_cast<unsigned char>(self->GetAlpha() * 255.0); |
| 1494 | |
| 1495 | if (self->GetSize() == 0) |
| 1496 | { |
| 1497 | vtkGenericWarningMacro("Transfer Function Has No Points!"); |
| 1498 | return; |
| 1499 | } |
| 1500 | |
| 1501 | while (--i >= 0) |
| 1502 | { |
| 1503 | x = static_cast<double>(*iptr); |
| 1504 | self->GetColor(x, rgb); |
| 1505 | |
| 1506 | if (outFormat == VTK_RGB || outFormat == VTK_RGBA) |
| 1507 | { |
| 1508 | *(optr++) = static_cast<unsigned char>(rgb[0] * 255.0 + 0.5); |
| 1509 | *(optr++) = static_cast<unsigned char>(rgb[1] * 255.0 + 0.5); |
| 1510 | *(optr++) = static_cast<unsigned char>(rgb[2] * 255.0 + 0.5); |
| 1511 | } |
| 1512 | else // LUMINANCE use coeffs of (0.30 0.59 0.11)*255.0 |
| 1513 | { |
| 1514 | *(optr++) = |
| 1515 | static_cast<unsigned char>(rgb[0] * 76.5 + rgb[1] * 150.45 + rgb[2] * 28.05 + 0.5); |
| 1516 | } |
| 1517 | |
| 1518 | if (outFormat == VTK_RGBA || outFormat == VTK_LUMINANCE_ALPHA) |
| 1519 | { |
| 1520 | *(optr++) = alpha; |
| 1521 | } |
| 1522 | iptr += inIncr; |
| 1523 | } |
| 1524 | } |
| 1525 | |
| 1526 | //------------------------------------------------------------------------------ |
| 1527 | // Special implementation for unsigned char input. |
no test coverage detected