changeset 208:315e1720a35f

documented orthanc.CreateImageFromBuffer()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 03 Jul 2024 12:56:18 +0200
parents 968dbd6982bb
children f6afd8edeb66
files CodeAnalysis/CustomFunctions.json Sources/Autogenerated/orthanc.pyi Sources/Autogenerated/sdk_GlobalFunctions.impl.h Sources/Plugin.cpp
diffstat 4 files changed, 62 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/CodeAnalysis/CustomFunctions.json	Wed Jul 03 12:38:31 2024 +0200
+++ b/CodeAnalysis/CustomFunctions.json	Wed Jul 03 12:56:18 2024 +0200
@@ -107,5 +107,47 @@
       }
     ],
     "return_sdk_type" : "Dictionary"
+  },
+
+  {
+    "comment" : "New in release 3.2",
+    "short_name" : "CreateImageFromBuffer",
+    "implementation" : "CreateImageFromBuffer",
+    "documentation" : {
+      "description" : [ "This function creates an image of given size and format, and initializes its pixel data from a memory buffer." ],
+      "args" : {
+        "format" : "The format of the pixels.",
+        "width" : "The width of the image.",
+        "height" : "The height of the image.",
+        "pitch" : "The pitch of the image (i.e. the number of bytes between 2 successive lines of the image in the memory buffer).",
+        "buffer" : "The memory buffer."
+      },
+      "return" : "The newly allocated image."
+    },
+    "args" : [
+      {
+        "sdk_name" : "format",
+        "sdk_type" : "enumeration",
+        "sdk_enumeration" : "OrthancPluginPixelFormat"
+      },
+      {
+        "sdk_name" : "width",
+        "sdk_type" : "uint32_t"
+      },
+      {
+        "sdk_name" : "height",
+        "sdk_type" : "uint32_t"
+      },
+      {
+        "sdk_name" : "pitch",
+        "sdk_type" : "uint32_t"
+      },
+      {
+        "sdk_name" : "buffer",
+        "sdk_type" : "const void *"
+      }
+    ],
+    "return_sdk_type" : "object",
+    "return_sdk_class" : "OrthancPluginImage"
   }
 ]
--- a/Sources/Autogenerated/orthanc.pyi	Wed Jul 03 12:38:31 2024 +0200
+++ b/Sources/Autogenerated/orthanc.pyi	Wed Jul 03 12:56:18 2024 +0200
@@ -2156,6 +2156,23 @@
     """
     ...
 
+# This function creates an image of given size and format, and initializes its pixel data from a memory buffer
+def CreateImageFromBuffer(format: PixelFormat, width: int, height: int, pitch: int, buffer: bytes) -> Image:
+    """
+    This function creates an image of given size and format, and initializes its pixel data from a memory buffer.
+
+    Args:
+      format (PixelFormat): The format of the pixels.
+      width (int): The width of the image.
+      height (int): The height of the image.
+      pitch (int): The pitch of the image (i.e. the number of bytes between 2 successive lines of the image in the memory buffer).
+      buffer (bytes): The memory buffer.
+
+    Returns:
+      Image: The newly allocated image.
+    """
+    ...
+
 # Get information about the given DICOM tag
 def LookupDictionary(name: str) -> dict:
     """
--- a/Sources/Autogenerated/sdk_GlobalFunctions.impl.h	Wed Jul 03 12:38:31 2024 +0200
+++ b/Sources/Autogenerated/sdk_GlobalFunctions.impl.h	Wed Jul 03 12:56:18 2024 +0200
@@ -23,6 +23,7 @@
 
 
 // Forward declaration of the custom global functions
+extern PyObject *CreateImageFromBuffer(PyObject* module, PyObject *args);
 extern PyObject *LookupDictionary(PyObject* module, PyObject *args);
 extern PyObject *RegisterIncomingHttpRequestFilter(PyObject* module, PyObject *args);
 extern PyObject *RegisterOnChangeCallback(PyObject* module, PyObject *args);
@@ -2021,6 +2022,8 @@
     "Generated from C function OrthancPluginUncompressImage()" },
   { "WriteFile", sdk_OrthancPluginWriteFile, METH_VARARGS,
     "Generated from C function OrthancPluginWriteFile()" },
+  { "CreateImageFromBuffer", CreateImageFromBuffer, METH_VARARGS,
+    "Implemented in C++ function CreateImageFromBuffer()" },
   { "LookupDictionary", LookupDictionary, METH_VARARGS,
     "Implemented in C++ function LookupDictionary()" },
   { "RegisterIncomingHttpRequestFilter", RegisterIncomingHttpRequestFilter, METH_VARARGS,
--- a/Sources/Plugin.cpp	Wed Jul 03 12:38:31 2024 +0200
+++ b/Sources/Plugin.cpp	Wed Jul 03 12:56:18 2024 +0200
@@ -289,11 +289,6 @@
    **/
   
   {
-    PyMethodDef f = { "CreateImageFromBuffer", CreateImageFromBuffer, METH_VARARGS, "" };
-    functions.push_back(f);
-  }
-  
-  {
     PyMethodDef f = { "RegisterFindCallback", RegisterFindCallback, METH_VARARGS, "" };
     functions.push_back(f);
   }