------------------------------------------------------------------------------
| 137 | |
| 138 | //------------------------------------------------------------------------------ |
| 139 | void vtkImageCanvasSource2D::DrawImage( |
| 140 | int x0, int y0, vtkImageData* image, int sx, int sy, int width, int height) |
| 141 | { |
| 142 | if (!image) |
| 143 | { |
| 144 | return; |
| 145 | } |
| 146 | |
| 147 | vtkImageClip* clip = vtkImageClip::New(); |
| 148 | clip->SetInputData(image); |
| 149 | |
| 150 | int* extent; |
| 151 | int ext[6]; |
| 152 | int z = this->DefaultZ; |
| 153 | image->GetExtent(ext); |
| 154 | if (sx < 0) |
| 155 | { |
| 156 | sx = ext[0]; |
| 157 | } |
| 158 | if (sy < 0) |
| 159 | { |
| 160 | sy = ext[2]; |
| 161 | } |
| 162 | if (width < 0) |
| 163 | { |
| 164 | width = ext[1] - ext[0] + 1; |
| 165 | } |
| 166 | else |
| 167 | { |
| 168 | width = vtkMath::Min(width, ext[1] - ext[0] + 1); |
| 169 | } |
| 170 | if (height < 0) |
| 171 | { |
| 172 | height = ext[3] - ext[2] + 1; |
| 173 | } |
| 174 | else |
| 175 | { |
| 176 | height = vtkMath::Min(height, ext[3] - ext[2] + 1); |
| 177 | } |
| 178 | ext[0] = vtkMath::Max(sx, ext[0]); |
| 179 | ext[1] = vtkMath::Max(sx + width - 1, ext[1]); |
| 180 | ext[2] = vtkMath::Max(sy, ext[2]); |
| 181 | ext[3] = vtkMath::Max(sy + height - 1, ext[3]); |
| 182 | clip->SetOutputWholeExtent(ext); |
| 183 | |
| 184 | vtkImageCast* ic = vtkImageCast::New(); |
| 185 | ic->SetInputConnection(clip->GetOutputPort()); |
| 186 | ic->SetOutputScalarType(this->ImageData->GetScalarType()); |
| 187 | ic->Update(); |
| 188 | int min0, max0, min1, max1; |
| 189 | min0 = x0; |
| 190 | min1 = y0; |
| 191 | |
| 192 | max0 = x0 + width - 1; |
| 193 | max1 = y0 + height - 1; |
| 194 | |
| 195 | // Pre-multiply coords if needed |
| 196 | if (this->Ratio[0] != 1.0) |
no test coverage detected