------------------------------------------------------------------------------ Fill a colored area with another color. (like connectivity) All pixels connected to pixel (x, y) get replaced by draw color.
| 1366 | // Fill a colored area with another color. (like connectivity) |
| 1367 | // All pixels connected to pixel (x, y) get replaced by draw color. |
| 1368 | void vtkImageCanvasSource2D::FillPixel(int x, int y) |
| 1369 | { |
| 1370 | void* ptr; |
| 1371 | int* ext = this->ImageData->GetExtent(); |
| 1372 | int z = this->DefaultZ; |
| 1373 | |
| 1374 | // Pre-multiply coords if needed |
| 1375 | if (this->Ratio[0] != 1.0) |
| 1376 | { |
| 1377 | x = static_cast<int>(static_cast<double>(x) * this->Ratio[0]); |
| 1378 | } |
| 1379 | if (this->Ratio[1] != 1.0) |
| 1380 | { |
| 1381 | y = static_cast<int>(static_cast<double>(y) * this->Ratio[1]); |
| 1382 | } |
| 1383 | if (this->Ratio[2] != 1.0) |
| 1384 | { |
| 1385 | z = static_cast<int>(static_cast<double>(z) * this->Ratio[2]); |
| 1386 | } |
| 1387 | |
| 1388 | z = (z < ext[4]) ? ext[4] : z; |
| 1389 | z = (z > ext[5]) ? ext[5] : z; |
| 1390 | |
| 1391 | ptr = this->ImageData->GetScalarPointer(x, y, z); |
| 1392 | |
| 1393 | switch (this->ImageData->GetScalarType()) |
| 1394 | { |
| 1395 | vtkTemplateMacro(vtkImageCanvasSource2DFill( |
| 1396 | this->ImageData, this->DrawColor, static_cast<VTK_TT*>(ptr), x, y)); |
| 1397 | default: |
| 1398 | vtkErrorMacro(<< "Fill: Cannot handle ScalarType."); |
| 1399 | } |
| 1400 | this->Modified(); |
| 1401 | } |
| 1402 | |
| 1403 | //------------------------------------------------------------------------------ |
| 1404 | void vtkImageCanvasSource2D::SetExtent(int* extent) |
no test coverage detected