changeset 1599:dd1f9e81f891

fixes to image primitives
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 01 Sep 2015 11:23:41 +0200
parents c6b50b803387
children 7151d63e6d81
files Plugins/Engine/OrthancPlugins.cpp Plugins/Include/orthanc/OrthancCDatabasePlugin.h Plugins/Include/orthanc/OrthancCPlugin.h
diffstat 3 files changed, 43 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/Plugins/Engine/OrthancPlugins.cpp	Mon Aug 31 17:37:54 2015 +0200
+++ b/Plugins/Engine/OrthancPlugins.cpp	Tue Sep 01 11:23:41 2015 +0200
@@ -1048,7 +1048,7 @@
 
   void OrthancPlugins::UncompressImage(const void* parameters)
   {
-    const _OrthancPluginUncompressImage& p = reinterpret_cast<const _OrthancPluginUncompressImage&>(parameters);
+    const _OrthancPluginUncompressImage& p = *reinterpret_cast<const _OrthancPluginUncompressImage*>(parameters);
 
     switch (p.format)
     {
@@ -1071,7 +1071,7 @@
 
   void OrthancPlugins::CompressImage(const void* parameters)
   {
-    const _OrthancPluginCompressImage& p = reinterpret_cast<const _OrthancPluginCompressImage&>(parameters);
+    const _OrthancPluginCompressImage& p = *reinterpret_cast<const _OrthancPluginCompressImage*>(parameters);
 
     std::string compressed;
 
@@ -1086,6 +1086,7 @@
 
       case OrthancPluginImageFormat_Jpeg:
         // TODO
+        //writer.SetQuality(p.quality);
 
       default:
         throw OrthancException(ErrorCode_ParameterOutOfRange);
@@ -1401,42 +1402,42 @@
 
       case _OrthancPluginService_GetImagePixelFormat:
       {
-        const _OrthancPluginGetImageInfo& p = reinterpret_cast<const _OrthancPluginGetImageInfo&>(parameters);
+        const _OrthancPluginGetImageInfo& p = *reinterpret_cast<const _OrthancPluginGetImageInfo*>(parameters);
         *(p.resultPixelFormat) = Convert(reinterpret_cast<const ImageAccessor*>(p.image)->GetFormat());
         return true;
       }
 
       case _OrthancPluginService_GetImageWidth:
       {
-        const _OrthancPluginGetImageInfo& p = reinterpret_cast<const _OrthancPluginGetImageInfo&>(parameters);
+        const _OrthancPluginGetImageInfo& p = *reinterpret_cast<const _OrthancPluginGetImageInfo*>(parameters);
         *(p.resultUint32) = reinterpret_cast<const ImageAccessor*>(p.image)->GetWidth();
         return true;
       }
 
       case _OrthancPluginService_GetImageHeight:
       {
-        const _OrthancPluginGetImageInfo& p = reinterpret_cast<const _OrthancPluginGetImageInfo&>(parameters);
+        const _OrthancPluginGetImageInfo& p = *reinterpret_cast<const _OrthancPluginGetImageInfo*>(parameters);
         *(p.resultUint32) = reinterpret_cast<const ImageAccessor*>(p.image)->GetHeight();
         return true;
       }
 
       case _OrthancPluginService_GetImagePitch:
       {
-        const _OrthancPluginGetImageInfo& p = reinterpret_cast<const _OrthancPluginGetImageInfo&>(parameters);
+        const _OrthancPluginGetImageInfo& p = *reinterpret_cast<const _OrthancPluginGetImageInfo*>(parameters);
         *(p.resultUint32) = reinterpret_cast<const ImageAccessor*>(p.image)->GetPitch();
         return true;
       }
 
       case _OrthancPluginService_GetImageBuffer:
       {
-        const _OrthancPluginGetImageInfo& p = reinterpret_cast<const _OrthancPluginGetImageInfo&>(parameters);
-        *(p.resultBuffer) = reinterpret_cast<const ImageAccessor*>(p.image)->GetBuffer();
+        const _OrthancPluginGetImageInfo& p = *reinterpret_cast<const _OrthancPluginGetImageInfo*>(parameters);
+        *(p.resultBuffer) = reinterpret_cast<const ImageAccessor*>(p.image)->GetConstBuffer();
         return true;
       }
 
       case _OrthancPluginService_FreeImage:
       {
-        const _OrthancPluginGetImageInfo& p = reinterpret_cast<const _OrthancPluginGetImageInfo&>(parameters);
+        const _OrthancPluginGetImageInfo& p = *reinterpret_cast<const _OrthancPluginGetImageInfo*>(parameters);
         delete reinterpret_cast<const ImageAccessor*>(p.image);
         return true;
       }
--- a/Plugins/Include/orthanc/OrthancCDatabasePlugin.h	Mon Aug 31 17:37:54 2015 +0200
+++ b/Plugins/Include/orthanc/OrthancCDatabasePlugin.h	Tue Sep 01 11:23:41 2015 +0200
@@ -54,7 +54,7 @@
   typedef struct _OrthancPluginDatabaseContext_t OrthancPluginDatabaseContext;
 
 
-//! @cond Doxygen_Suppress
+/*<! @cond Doxygen_Suppress */
   typedef enum
   {
     _OrthancPluginDatabaseAnswerType_None = 0,
@@ -629,7 +629,7 @@
       void* payload);
 
   } OrthancPluginDatabaseBackend;
-//! @endcond
+/*<! @endcond */
 
 
   typedef struct
--- a/Plugins/Include/orthanc/OrthancCPlugin.h	Mon Aug 31 17:37:54 2015 +0200
+++ b/Plugins/Include/orthanc/OrthancCPlugin.h	Tue Sep 01 11:23:41 2015 +0200
@@ -1369,7 +1369,7 @@
     params.result = &result;
     params.argument = patientID;
 
-    if (context->InvokeService(context, _OrthancPluginService_LookupPatient, &params))
+    if (context->InvokeService(context, _OrthancPluginService_LookupPatient, &params) != OrthancPluginErrorCode_Success)
     {
       /* Error */
       return NULL;
@@ -1403,7 +1403,7 @@
     params.result = &result;
     params.argument = studyUID;
 
-    if (context->InvokeService(context, _OrthancPluginService_LookupStudy, &params))
+    if (context->InvokeService(context, _OrthancPluginService_LookupStudy, &params) != OrthancPluginErrorCode_Success)
     {
       /* Error */
       return NULL;
@@ -1437,7 +1437,7 @@
     params.result = &result;
     params.argument = accessionNumber;
 
-    if (context->InvokeService(context, _OrthancPluginService_LookupStudyWithAccessionNumber, &params))
+    if (context->InvokeService(context, _OrthancPluginService_LookupStudyWithAccessionNumber, &params) != OrthancPluginErrorCode_Success)
     {
       /* Error */
       return NULL;
@@ -1471,7 +1471,7 @@
     params.result = &result;
     params.argument = seriesUID;
 
-    if (context->InvokeService(context, _OrthancPluginService_LookupSeries, &params))
+    if (context->InvokeService(context, _OrthancPluginService_LookupSeries, &params) != OrthancPluginErrorCode_Success)
     {
       /* Error */
       return NULL;
@@ -1505,7 +1505,7 @@
     params.result = &result;
     params.argument = sopInstanceUID;
 
-    if (context->InvokeService(context, _OrthancPluginService_LookupInstance, &params))
+    if (context->InvokeService(context, _OrthancPluginService_LookupInstance, &params) != OrthancPluginErrorCode_Success)
     {
       /* Error */
       return NULL;
@@ -1681,7 +1681,7 @@
     params.resultString = &result;
     params.instance = instance;
 
-    if (context->InvokeService(context, _OrthancPluginService_GetInstanceRemoteAet, &params))
+    if (context->InvokeService(context, _OrthancPluginService_GetInstanceRemoteAet, &params) != OrthancPluginErrorCode_Success)
     {
       /* Error */
       return NULL;
@@ -1713,7 +1713,7 @@
     params.resultInt64 = &size;
     params.instance = instance;
 
-    if (context->InvokeService(context, _OrthancPluginService_GetInstanceSize, &params))
+    if (context->InvokeService(context, _OrthancPluginService_GetInstanceSize, &params) != OrthancPluginErrorCode_Success)
     {
       /* Error */
       return -1;
@@ -1745,7 +1745,7 @@
     params.resultString = &result;
     params.instance = instance;
 
-    if (context->InvokeService(context, _OrthancPluginService_GetInstanceData, &params))
+    if (context->InvokeService(context, _OrthancPluginService_GetInstanceData, &params) != OrthancPluginErrorCode_Success)
     {
       /* Error */
       return NULL;
@@ -1780,7 +1780,7 @@
     params.resultStringToFree = &result;
     params.instance = instance;
 
-    if (context->InvokeService(context, _OrthancPluginService_GetInstanceJson, &params))
+    if (context->InvokeService(context, _OrthancPluginService_GetInstanceJson, &params) != OrthancPluginErrorCode_Success)
     {
       /* Error */
       return NULL;
@@ -1817,7 +1817,7 @@
     params.resultStringToFree = &result;
     params.instance = instance;
 
-    if (context->InvokeService(context, _OrthancPluginService_GetInstanceSimplifiedJson, &params))
+    if (context->InvokeService(context, _OrthancPluginService_GetInstanceSimplifiedJson, &params) != OrthancPluginErrorCode_Success)
     {
       /* Error */
       return NULL;
@@ -1857,7 +1857,7 @@
     params.instance = instance;
     params.key = metadata;
 
-    if (context->InvokeService(context, _OrthancPluginService_HasInstanceMetadata, &params))
+    if (context->InvokeService(context, _OrthancPluginService_HasInstanceMetadata, &params) != OrthancPluginErrorCode_Success)
     {
       /* Error */
       return -1;
@@ -1894,7 +1894,7 @@
     params.instance = instance;
     params.key = metadata;
 
-    if (context->InvokeService(context, _OrthancPluginService_GetInstanceMetadata, &params))
+    if (context->InvokeService(context, _OrthancPluginService_GetInstanceMetadata, &params) != OrthancPluginErrorCode_Success)
     {
       /* Error */
       return NULL;
@@ -1968,7 +1968,7 @@
     params.result = &result;
     params.argument = NULL;
 
-    if (context->InvokeService(context, _OrthancPluginService_GetOrthancPath, &params))
+    if (context->InvokeService(context, _OrthancPluginService_GetOrthancPath, &params) != OrthancPluginErrorCode_Success)
     {
       /* Error */
       return NULL;
@@ -1998,7 +1998,7 @@
     params.result = &result;
     params.argument = NULL;
 
-    if (context->InvokeService(context, _OrthancPluginService_GetOrthancDirectory, &params))
+    if (context->InvokeService(context, _OrthancPluginService_GetOrthancDirectory, &params) != OrthancPluginErrorCode_Success)
     {
       /* Error */
       return NULL;
@@ -2033,7 +2033,7 @@
     params.result = &result;
     params.argument = NULL;
 
-    if (context->InvokeService(context, _OrthancPluginService_GetConfigurationPath, &params))
+    if (context->InvokeService(context, _OrthancPluginService_GetConfigurationPath, &params) != OrthancPluginErrorCode_Success)
     {
       /* Error */
       return NULL;
@@ -2180,7 +2180,7 @@
     params.property = property;
     params.value = defaultValue;
 
-    if (context->InvokeService(context, _OrthancPluginService_GetGlobalProperty, &params))
+    if (context->InvokeService(context, _OrthancPluginService_GetGlobalProperty, &params) != OrthancPluginErrorCode_Success)
     {
       /* Error */
       return NULL;
@@ -2246,7 +2246,7 @@
     memset(&params, 0, sizeof(params));
     params.resultUint32 = &count;
 
-    if (context->InvokeService(context, _OrthancPluginService_GetCommandLineArgumentsCount, &params))
+    if (context->InvokeService(context, _OrthancPluginService_GetCommandLineArgumentsCount, &params) != OrthancPluginErrorCode_Success)
     {
       /* Error */
       return 0;
@@ -2282,7 +2282,7 @@
     params.property = (int32_t) argument;
     params.value = NULL;
 
-    if (context->InvokeService(context, _OrthancPluginService_GetCommandLineArgument, &params))
+    if (context->InvokeService(context, _OrthancPluginService_GetCommandLineArgument, &params) != OrthancPluginErrorCode_Success)
     {
       /* Error */
       return NULL;
@@ -2311,7 +2311,7 @@
     memset(&params, 0, sizeof(params));
     params.resultUint32 = &count;
 
-    if (context->InvokeService(context, _OrthancPluginService_GetExpectedDatabaseVersion, &params))
+    if (context->InvokeService(context, _OrthancPluginService_GetExpectedDatabaseVersion, &params) != OrthancPluginErrorCode_Success)
     {
       /* Error */
       return 0;
@@ -2343,7 +2343,7 @@
     params.result = &result;
     params.argument = NULL;
 
-    if (context->InvokeService(context, _OrthancPluginService_GetConfiguration, &params))
+    if (context->InvokeService(context, _OrthancPluginService_GetConfiguration, &params) != OrthancPluginErrorCode_Success)
     {
       /* Error */
       return NULL;
@@ -2552,7 +2552,7 @@
     params.target = &result;
     params.error = error;
 
-    if (context->InvokeService(context, _OrthancPluginService_GetErrorDescription, &params) ||
+    if (context->InvokeService(context, _OrthancPluginService_GetErrorDescription, &params) != OrthancPluginErrorCode_Success ||
         result == NULL)
     {
       return "Unknown error code";
@@ -2631,13 +2631,13 @@
     params.image = image;
     params.resultPixelFormat = &target;
 
-    if (context->InvokeService(context, _OrthancPluginService_GetImagePixelFormat, image) < 0)
+    if (context->InvokeService(context, _OrthancPluginService_GetImagePixelFormat, &params) != OrthancPluginErrorCode_Success)
     {
       return OrthancPluginPixelFormat_Unknown;
     }
     else
     {
-      return static_cast<OrthancPluginPixelFormat>(target);
+      return (OrthancPluginPixelFormat) target;
     }
   }
 
@@ -2654,7 +2654,7 @@
     params.image = image;
     params.resultUint32 = &width;
 
-    if (context->InvokeService(context, _OrthancPluginService_GetImagePixelFormat, image) < 0)
+    if (context->InvokeService(context, _OrthancPluginService_GetImageWidth, &params) != OrthancPluginErrorCode_Success)
     {
       return 0;
     }
@@ -2677,7 +2677,7 @@
     params.image = image;
     params.resultUint32 = &height;
 
-    if (context->InvokeService(context, _OrthancPluginService_GetImagePixelFormat, image) < 0)
+    if (context->InvokeService(context, _OrthancPluginService_GetImageHeight, &params) != OrthancPluginErrorCode_Success)
     {
       return 0;
     }
@@ -2700,7 +2700,7 @@
     params.image = image;
     params.resultUint32 = &pitch;
 
-    if (context->InvokeService(context, _OrthancPluginService_GetImagePixelFormat, image) < 0)
+    if (context->InvokeService(context, _OrthancPluginService_GetImagePitch, &params) != OrthancPluginErrorCode_Success)
     {
       return 0;
     }
@@ -2723,7 +2723,7 @@
     params.resultBuffer = &target;
     params.image = image;
 
-    if (context->InvokeService(context, _OrthancPluginService_GetImageBuffer, &params) < 0)
+    if (context->InvokeService(context, _OrthancPluginService_GetImageBuffer, &params) != OrthancPluginErrorCode_Success)
     {
       return NULL;
     }
@@ -2757,7 +2757,7 @@
     params.size = size;
     params.format = format;
 
-    if (context->InvokeService(context, _OrthancPluginService_UncompressImage, &params) < 0)
+    if (context->InvokeService(context, _OrthancPluginService_UncompressImage, &params) != OrthancPluginErrorCode_Success)
     {
       return NULL;
     }
@@ -2792,7 +2792,7 @@
     uint32_t                   height;
     uint32_t                   pitch;
     const void*                buffer;
-    uint32_t                   quality;
+    uint8_t                    quality;
   } _OrthancPluginCompressImage;
 
 
@@ -2804,8 +2804,7 @@
     uint32_t                      width,
     uint32_t                      height,
     uint32_t                      pitch,
-    const void*                   buffer,
-    uint32_t                      quality)
+    const void*                   buffer)
   {
     _OrthancPluginCompressImage params;
     memset(&params, 0, sizeof(params));
@@ -2816,7 +2815,7 @@
     params.height = height;
     params.pitch = pitch;
     params.buffer = buffer;
-    params.quality = quality;
+    params.quality = 0;  // Unused for PNG
 
     return context->InvokeService(context, _OrthancPluginService_CompressImage, &params);
   }