changeset 3372:ff945b809067

added ImagePoint::ClipTo
author amazy
date Tue, 14 May 2019 12:06:25 +0200
parents fe73717105b6
children 4a8e8a96b233
files Core/Images/ImageProcessing.h
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Core/Images/ImageProcessing.h	Tue May 14 11:01:17 2019 +0200
+++ b/Core/Images/ImageProcessing.h	Tue May 14 12:06:25 2019 +0200
@@ -37,6 +37,7 @@
 #include <vector>
 
 #include <stdint.h>
+#include <algorithm>
 
 namespace Orthanc
 {
@@ -64,6 +65,12 @@
         y_ = y;
       }
 
+      void ClipTo(int32_t minX, int32_t maxX, int32_t minY, int32_t maxY)
+      {
+        x_ = std::max(minX, std::min(maxX, x_));
+        y_ = std::max(minY, std::min(maxY, y_));
+      }
+
       double GetDistanceTo(const ImagePoint& other) const;
     };