changeset 2490:0cacb38297a9

speed up ImageProcessing::Set
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 14 Mar 2018 13:46:17 +0100
parents e91bab2d8c75
children a9459c7d4bc2
files Core/Images/ImageProcessing.cpp
diffstat 1 files changed, 24 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Core/Images/ImageProcessing.cpp	Tue Mar 13 21:14:21 2018 +0100
+++ b/Core/Images/ImageProcessing.cpp	Wed Mar 14 13:46:17 2018 +0100
@@ -627,15 +627,36 @@
         return;
 
       case PixelFormat_Grayscale16:
-        SetInternal<uint16_t>(image, value);
+        if (value == 0)
+        {
+          memset(image.GetBuffer(), 0, image.GetPitch() * image.GetHeight());
+        }
+        else
+        {
+          SetInternal<uint16_t>(image, value);
+        }
         return;
 
       case PixelFormat_Grayscale32:
-        SetInternal<uint32_t>(image, value);
+        if (value == 0)
+        {
+          memset(image.GetBuffer(), 0, image.GetPitch() * image.GetHeight());
+        }
+        else
+        {
+          SetInternal<uint32_t>(image, value);
+        }
         return;
 
       case PixelFormat_SignedGrayscale16:
-        SetInternal<int16_t>(image, value);
+        if (value == 0)
+        {
+          memset(image.GetBuffer(), 0, image.GetPitch() * image.GetHeight());
+        }
+        else
+        {
+          SetInternal<int16_t>(image, value);
+        }
         return;
 
       case PixelFormat_Float32: