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

Method DrawImage

Imaging/Sources/vtkImageCanvasSource2D.cxx:139–236  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

137
138//------------------------------------------------------------------------------
139void 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)

Callers 2

DrawImageFunction · 0.45
TestImageCanvas.pyFile · 0.45

Calls 15

MinFunction · 0.85
SetOutputScalarTypeMethod · 0.80
GetScalarPointerMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50
MaxFunction · 0.50
SetInputDataMethod · 0.45
GetExtentMethod · 0.45
SetOutputWholeExtentMethod · 0.45
SetInputConnectionMethod · 0.45
GetOutputPortMethod · 0.45

Tested by

no test coverage detected