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

Method MakeTextureData

Rendering/Core/vtkImageMapper3D.cxx:758–903  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

756}
757
758unsigned 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 {

Callers 1

RenderTexturedPolygonMethod · 0.80

Calls 15

ComputeTextureSizeMethod · 0.95
vtkImageMapperCopyFunction · 0.85
GetColorWindowMethod · 0.80
GetColorLevelMethod · 0.80
GetIncrementsMethod · 0.80
GetScalarTypeMethod · 0.45
GetLookupTableMethod · 0.45
GetExtentMethod · 0.45
SetRangeMethod · 0.45
BuildMethod · 0.45

Tested by

no test coverage detected