changeset 677:077f28e3ea3d am-dev

clip mask before drawing
author Alain Mazy <alain@mazy.be>
date Thu, 16 May 2019 10:46:35 +0200
parents 1b47f17863ba
children e8b83fe55a33
files Framework/Radiography/RadiographyMaskLayer.cpp
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Radiography/RadiographyMaskLayer.cpp	Thu May 16 09:49:30 2019 +0200
+++ b/Framework/Radiography/RadiographyMaskLayer.cpp	Thu May 16 10:46:35 2019 +0200
@@ -135,8 +135,16 @@
     // first fill the complete image
     Orthanc::ImageProcessing::Set(*mask_, OUT_MASK_VALUE);
 
+    // clip corners
+    std::vector<Orthanc::ImageProcessing::ImagePoint> clippedCorners;
+    for (size_t i = 0; i < corners_.size(); i++)
+    {
+      clippedCorners.push_back(corners_[i]);
+      clippedCorners[i].ClipTo(0, mask_->GetWidth() - 1, 0, mask_->GetHeight() - 1);
+    }
+
     // fill mask
-    Orthanc::ImageProcessing::FillPolygon(*mask_, corners_, IN_MASK_VALUE);
+    Orthanc::ImageProcessing::FillPolygon(*mask_, clippedCorners, IN_MASK_VALUE);
 
   }