| 143 | |
| 144 | template <class T> |
| 145 | void vtkOpenGLImageMapperRenderDouble(vtkOpenGLImageMapper* self, vtkImageData* data, T* dataPtr, |
| 146 | double shift, double scale, vtkViewport* viewport) |
| 147 | { |
| 148 | vtkOpenGLClearErrorMacro(); |
| 149 | |
| 150 | int inMin0 = self->DisplayExtent[0]; |
| 151 | int inMax0 = self->DisplayExtent[1]; |
| 152 | int inMin1 = self->DisplayExtent[2]; |
| 153 | int inMax1 = self->DisplayExtent[3]; |
| 154 | |
| 155 | int width = inMax0 - inMin0 + 1; |
| 156 | int height = inMax1 - inMin1 + 1; |
| 157 | |
| 158 | vtkIdType tempIncs[3]; |
| 159 | data->GetIncrements(tempIncs); |
| 160 | vtkIdType inInc1 = tempIncs[1]; |
| 161 | |
| 162 | int bpp = data->GetNumberOfScalarComponents(); |
| 163 | double range[2]; |
| 164 | data->GetPointData()->GetScalars()->GetDataTypeRange(range); |
| 165 | |
| 166 | auto ostate = static_cast<vtkOpenGLRenderWindow*>(viewport->GetVTKWindow())->GetState(); |
| 167 | ostate->vtkglPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 168 | |
| 169 | // reformat data into unsigned char |
| 170 | |
| 171 | T* inPtr = dataPtr; |
| 172 | T* inPtr1 = inPtr; |
| 173 | |
| 174 | int i; |
| 175 | int j = height; |
| 176 | |
| 177 | unsigned char* newPtr; |
| 178 | if (bpp < 4) |
| 179 | { |
| 180 | newPtr = new unsigned char[vtkPadToFour(3 * width * height)]; |
| 181 | } |
| 182 | else |
| 183 | { |
| 184 | newPtr = new unsigned char[4 * width * height]; |
| 185 | } |
| 186 | |
| 187 | unsigned char* ptr = newPtr; |
| 188 | double val; |
| 189 | unsigned char tmp; |
| 190 | |
| 191 | while (--j >= 0) |
| 192 | { |
| 193 | inPtr = inPtr1; |
| 194 | i = width; |
| 195 | switch (bpp) |
| 196 | { |
| 197 | case 1: |
| 198 | while (--i >= 0) |
| 199 | { |
| 200 | vtkClampToUnsignedChar(tmp, ((*inPtr++ + shift) * scale)); |
| 201 | *ptr++ = tmp; |
| 202 | *ptr++ = tmp; |
no test coverage detected