| 756 | } |
| 757 | |
| 758 | unsigned char* vtkImageMapper3D::MakeTextureData(vtkImageProperty* property, vtkImageData* input, |
| 759 | int extent[6], int& xsize, int& ysize, int& bytesPerPixel, bool& reuseTexture, bool& reuseData) |
| 760 | { |
| 761 | int xdim, ydim; |
| 762 | int imageSize[2]; |
| 763 | int textureSize[2]; |
| 764 | |
| 765 | // compute image size and texture size from extent |
| 766 | this->ComputeTextureSize(extent, xdim, ydim, imageSize, textureSize); |
| 767 | |
| 768 | // number of components |
| 769 | int numComp = input->GetNumberOfScalarComponents(); |
| 770 | int scalarType = input->GetScalarType(); |
| 771 | int textureBytesPerPixel = 4; |
| 772 | |
| 773 | // lookup table and window/level |
| 774 | double colorWindow = 255.0; |
| 775 | double colorLevel = 127.5; |
| 776 | vtkScalarsToColors* lookupTable = nullptr; |
| 777 | |
| 778 | if (property) |
| 779 | { |
| 780 | colorWindow = property->GetColorWindow(); |
| 781 | colorLevel = property->GetColorLevel(); |
| 782 | lookupTable = property->GetLookupTable(); |
| 783 | } |
| 784 | |
| 785 | // check if the input is pre-formatted as colors |
| 786 | int inputIsColors = false; |
| 787 | if (lookupTable == nullptr && scalarType == VTK_UNSIGNED_CHAR && colorLevel == 127.5 && |
| 788 | colorWindow == 255.0) |
| 789 | { |
| 790 | inputIsColors = true; |
| 791 | if (reuseData && numComp < 4) |
| 792 | { |
| 793 | textureBytesPerPixel = numComp; |
| 794 | } |
| 795 | } |
| 796 | |
| 797 | // reuse texture if texture size has not changed |
| 798 | if (xsize == textureSize[0] && ysize == textureSize[1] && bytesPerPixel == textureBytesPerPixel && |
| 799 | reuseTexture) |
| 800 | { |
| 801 | // if texture is reused, only reload the image portion |
| 802 | xsize = imageSize[0]; |
| 803 | ysize = imageSize[1]; |
| 804 | } |
| 805 | else |
| 806 | { |
| 807 | xsize = textureSize[0]; |
| 808 | ysize = textureSize[1]; |
| 809 | bytesPerPixel = textureBytesPerPixel; |
| 810 | reuseTexture = false; |
| 811 | } |
| 812 | |
| 813 | // if the image is already of the desired size and type |
| 814 | if (xsize == imageSize[0] && ysize == imageSize[1]) |
| 815 | { |
no test coverage detected