changeset 207:3d3d00e3e715

fix for new ImageAccessor API
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 08 Oct 2018 11:44:44 +0200
parents d1ed9efdea6c
children 9f443b9de579
files Plugin/DecodedImageAdapter.cpp Plugin/ViewerToolbox.cpp Plugin/ViewerToolbox.h
diffstat 3 files changed, 15 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/Plugin/DecodedImageAdapter.cpp	Fri Jul 20 14:25:04 2018 +0200
+++ b/Plugin/DecodedImageAdapter.cpp	Mon Oct 08 11:44:44 2018 +0200
@@ -323,14 +323,14 @@
     switch (accessor.GetFormat())
     {
       case Orthanc::PixelFormat_RGB24:
-        converted = accessor;
+        accessor.GetReadOnlyAccessor(converted);
         break;
 
       case Orthanc::PixelFormat_RGB48:
         buffer.reset(new Orthanc::ImageBuffer(Orthanc::PixelFormat_RGB24,
                                               accessor.GetWidth(),
                                               accessor.GetHeight(), false));
-        converted = buffer->GetAccessor();
+        buffer->GetWriteableAccessor(converted);
         ConvertRGB48ToRGB24(converted, accessor);
         break;
 
@@ -340,12 +340,12 @@
                                               accessor.GetWidth(),
                                               accessor.GetHeight(),
                                               true /* force minimal pitch */));
-        converted = buffer->GetAccessor();
+        buffer->GetWriteableAccessor(converted);
         Orthanc::ImageProcessing::Convert(converted, accessor);
         break;
 
       case Orthanc::PixelFormat_SignedGrayscale16:
-        converted = accessor;
+        accessor.GetReadOnlyAccessor(converted);
         break;
 
       default:
@@ -434,7 +434,7 @@
         accessor.GetFormat() == Orthanc::PixelFormat_RGB24)
     {
       result["Orthanc"]["Stretched"] = false;
-      converted = accessor;
+      accessor.GetReadOnlyAccessor(converted);
     }
     else if (accessor.GetFormat() == Orthanc::PixelFormat_RGB48)
     {
@@ -443,7 +443,8 @@
       buffer.reset(new Orthanc::ImageBuffer(Orthanc::PixelFormat_RGB24,
                                             accessor.GetWidth(),
                                             accessor.GetHeight(), false));
-      converted = buffer->GetAccessor();
+      buffer->GetWriteableAccessor(converted);
+      
       ConvertRGB48ToRGB24(converted, accessor);
     }
     else if (accessor.GetFormat() == Orthanc::PixelFormat_Grayscale16 ||
@@ -455,7 +456,7 @@
                                             accessor.GetWidth(),
                                             accessor.GetHeight(),
                                             true /* force minimal pitch */));
-      converted = buffer->GetAccessor();
+      buffer->GetWriteableAccessor(converted);
 
       int64_t a, b;
       Orthanc::ImageProcessing::GetMinMaxIntegerValue(a, b, accessor);
--- a/Plugin/ViewerToolbox.cpp	Fri Jul 20 14:25:04 2018 +0200
+++ b/Plugin/ViewerToolbox.cpp	Mon Oct 08 11:44:44 2018 +0200
@@ -383,16 +383,12 @@
   }
 
 
-  Orthanc::ImageAccessor ImageReader::GetAccessor() const
+  void ImageReader::GetAccessor(Orthanc::ImageAccessor& target) const
   {
-    Orthanc::ImageAccessor accessor;
-
-    accessor.AssignReadOnly(Convert(OrthancPluginGetImagePixelFormat(context_, image_)),
-                            OrthancPluginGetImageWidth(context_, image_),
-                            OrthancPluginGetImageHeight(context_, image_),
-                            OrthancPluginGetImagePitch(context_, image_),
-                            OrthancPluginGetImageBuffer(context_, image_));
-
-    return accessor;
+    target.AssignReadOnly(Convert(OrthancPluginGetImagePixelFormat(context_, image_)),
+                          OrthancPluginGetImageWidth(context_, image_),
+                          OrthancPluginGetImageHeight(context_, image_),
+                          OrthancPluginGetImagePitch(context_, image_),
+                          OrthancPluginGetImageBuffer(context_, image_));
   }
 }
--- a/Plugin/ViewerToolbox.h	Fri Jul 20 14:25:04 2018 +0200
+++ b/Plugin/ViewerToolbox.h	Mon Oct 08 11:44:44 2018 +0200
@@ -90,6 +90,6 @@
 
     ~ImageReader();
 
-    Orthanc::ImageAccessor GetAccessor() const;
+    void GetAccessor(Orthanc::ImageAccessor& target) const;
   };
 }