# HG changeset patch # User Sebastien Jodogne # Date 1478596505 -3600 # Node ID d850500b8ca6f65a276e373d2dd656a0bf973c2c # Parent daf99382bc18b873591de56a94b4005fd670daf9 sync diff -r daf99382bc18 -r d850500b8ca6 CMakeLists.txt --- a/CMakeLists.txt Fri Sep 16 09:19:10 2016 +0200 +++ b/CMakeLists.txt Tue Nov 08 10:15:05 2016 +0100 @@ -40,6 +40,7 @@ mark_as_advanced(USE_GTEST_DEBIAN_SOURCE_PACKAGE) set(ORTHANC_ROOT ${CMAKE_SOURCE_DIR}/Orthanc) +set(ORTHANC_DISABLE_PATCH ON) # No need for the "patch" command-line tool include(CheckIncludeFiles) include(CheckIncludeFileCXX) include(CheckLibraryExists) diff -r daf99382bc18 -r d850500b8ca6 Orthanc/Core/Enumerations.cpp --- a/Orthanc/Core/Enumerations.cpp Fri Sep 16 09:19:10 2016 +0200 +++ b/Orthanc/Core/Enumerations.cpp Tue Nov 08 10:15:05 2016 +0100 @@ -733,6 +733,9 @@ case PixelFormat_RGBA32: return "RGBA32"; + case PixelFormat_BGRA32: + return "BGRA32"; + case PixelFormat_Grayscale8: return "Grayscale (unsigned 8bpp)"; @@ -1061,6 +1064,7 @@ return 3; case PixelFormat_RGBA32: + case PixelFormat_BGRA32: return 4; case PixelFormat_Float32: diff -r daf99382bc18 -r d850500b8ca6 Orthanc/Core/Enumerations.h --- a/Orthanc/Core/Enumerations.h Fri Sep 16 09:19:10 2016 +0200 +++ b/Orthanc/Core/Enumerations.h Tue Nov 08 10:15:05 2016 +0100 @@ -195,7 +195,10 @@ * {summary}{Graylevel, floating-point image.} * {description}{The image is graylevel. Each pixel is floating-point and stored in 4 bytes.} **/ - PixelFormat_Float32 = 6 + PixelFormat_Float32 = 6, + + // This is the memory layout for Cairo + PixelFormat_BGRA32 = 7 }; diff -r daf99382bc18 -r d850500b8ca6 Orthanc/Core/FileStorage/FilesystemStorage.cpp --- a/Orthanc/Core/FileStorage/FilesystemStorage.cpp Fri Sep 16 09:19:10 2016 +0200 +++ b/Orthanc/Core/FileStorage/FilesystemStorage.cpp Tue Nov 08 10:15:05 2016 +0100 @@ -86,11 +86,37 @@ Toolbox::MakeDirectory(root); } + + + static const char* GetDescriptionInternal(FileContentType content) + { + // This function is for logging only (internal use), a more + // fully-featured version is available in ServerEnumerations.cpp + switch (content) + { + case FileContentType_Unknown: + return "Unknown"; + + case FileContentType_Dicom: + return "DICOM"; + + case FileContentType_DicomAsJson: + return "JSON summary of DICOM"; + + default: + return "User-defined"; + } + } + + void FilesystemStorage::Create(const std::string& uuid, const void* content, size_t size, - FileContentType /*type*/) + FileContentType type) { + LOG(INFO) << "Creating attachment \"" << uuid << "\" of \"" << GetDescriptionInternal(type) + << "\" type (size: " << (size / (1024 * 1024) + 1) << "MB)"; + boost::filesystem::path path; path = GetPath(uuid); @@ -117,31 +143,17 @@ } } - boost::filesystem::ofstream f; - f.open(path, std::ofstream::out | std::ios::binary); - if (!f.good()) - { - throw OrthancException(ErrorCode_FileStorageCannotWrite); - } - - if (size != 0) - { - f.write(static_cast(content), size); - if (!f.good()) - { - f.close(); - throw OrthancException(ErrorCode_FileStorageCannotWrite); - } - } - - f.close(); + Toolbox::WriteFile(content, size, path.string()); } void FilesystemStorage::Read(std::string& content, const std::string& uuid, - FileContentType /*type*/) + FileContentType type) { + LOG(INFO) << "Reading attachment \"" << uuid << "\" of \"" << GetDescriptionInternal(type) + << "\" content type"; + content.clear(); Toolbox::ReadFile(content, GetPath(uuid).string()); } @@ -211,11 +223,9 @@ void FilesystemStorage::Remove(const std::string& uuid, - FileContentType /*type*/) + FileContentType type) { -#if ORTHANC_ENABLE_GOOGLE_LOG == 1 - LOG(INFO) << "Deleting file " << uuid; -#endif + LOG(INFO) << "Deleting attachment \"" << uuid << "\" of type " << static_cast(type); namespace fs = boost::filesystem; diff -r daf99382bc18 -r d850500b8ca6 Orthanc/Core/Images/ImageAccessor.cpp --- a/Orthanc/Core/Images/ImageAccessor.cpp Fri Sep 16 09:19:10 2016 +0200 +++ b/Orthanc/Core/Images/ImageAccessor.cpp Tue Nov 08 10:15:05 2016 +0100 @@ -275,4 +275,22 @@ return result; } + + void ImageAccessor::SetFormat(PixelFormat format) + { + if (readOnly_) + { +#if ORTHANC_ENABLE_LOGGING == 1 + LOG(ERROR) << "Trying to modify the format of a read-only image"; +#endif + throw OrthancException(ErrorCode_ReadOnly); + } + + if (::Orthanc::GetBytesPerPixel(format) != ::Orthanc::GetBytesPerPixel(format_)) + { + throw OrthancException(ErrorCode_IncompatibleImageFormat); + } + + format_ = format; + } } diff -r daf99382bc18 -r d850500b8ca6 Orthanc/Core/Images/ImageAccessor.h --- a/Orthanc/Core/Images/ImageAccessor.h Fri Sep 16 09:19:10 2016 +0200 +++ b/Orthanc/Core/Images/ImageAccessor.h Tue Nov 08 10:15:05 2016 +0100 @@ -125,5 +125,7 @@ unsigned int y, unsigned int width, unsigned int height) const; + + void SetFormat(PixelFormat format); }; } diff -r daf99382bc18 -r d850500b8ca6 Orthanc/Core/Images/ImageBuffer.cpp --- a/Orthanc/Core/Images/ImageBuffer.cpp Fri Sep 16 09:19:10 2016 +0200 +++ b/Orthanc/Core/Images/ImageBuffer.cpp Tue Nov 08 10:15:05 2016 +0100 @@ -87,7 +87,9 @@ ImageBuffer::ImageBuffer(PixelFormat format, unsigned int width, - unsigned int height) + unsigned int height, + bool forceMinimalPitch) : + forceMinimalPitch_(forceMinimalPitch) { Initialize(); SetWidth(width); @@ -158,16 +160,6 @@ } - void ImageBuffer::SetMinimalPitchForced(bool force) - { - if (force != forceMinimalPitch_) - { - changed_ = true; - forceMinimalPitch_ = force; - } - } - - void ImageBuffer::AcquireOwnership(ImageBuffer& other) { // Remove the content of the current image diff -r daf99382bc18 -r d850500b8ca6 Orthanc/Core/Images/ImageBuffer.h --- a/Orthanc/Core/Images/ImageBuffer.h Fri Sep 16 09:19:10 2016 +0200 +++ b/Orthanc/Core/Images/ImageBuffer.h Tue Nov 08 10:15:05 2016 +0100 @@ -61,7 +61,8 @@ public: ImageBuffer(PixelFormat format, unsigned int width, - unsigned int height); + unsigned int height, + bool forceMinimalPitch); ImageBuffer() { @@ -108,8 +109,6 @@ return forceMinimalPitch_; } - void SetMinimalPitchForced(bool force); - void AcquireOwnership(ImageBuffer& other); }; } diff -r daf99382bc18 -r d850500b8ca6 Orthanc/Core/Images/ImageProcessing.cpp --- a/Orthanc/Core/Images/ImageProcessing.cpp Fri Sep 16 09:19:10 2016 +0200 +++ b/Orthanc/Core/Images/ImageProcessing.cpp Tue Nov 08 10:15:05 2016 +0100 @@ -519,6 +519,27 @@ return; } + if (target.GetFormat() == PixelFormat_BGRA32 && + source.GetFormat() == PixelFormat_RGB24) + { + for (unsigned int y = 0; y < source.GetHeight(); y++) + { + const uint8_t* p = reinterpret_cast(source.GetConstRow(y)); + uint8_t* q = reinterpret_cast(target.GetRow(y)); + for (unsigned int x = 0; x < source.GetWidth(); x++) + { + q[0] = p[2]; + q[1] = p[1]; + q[2] = p[0]; + q[3] = 255; + p += 3; + q += 4; + } + } + + return; + } + throw OrthancException(ErrorCode_NotImplemented); } @@ -552,6 +573,61 @@ } + void ImageProcessing::Set(ImageAccessor& image, + uint8_t red, + uint8_t green, + uint8_t blue, + uint8_t alpha) + { + uint8_t p[4]; + unsigned int size; + + switch (image.GetFormat()) + { + case PixelFormat_RGBA32: + p[0] = red; + p[1] = green; + p[2] = blue; + p[3] = alpha; + size = 4; + break; + + case PixelFormat_BGRA32: + p[0] = blue; + p[1] = green; + p[2] = red; + p[3] = alpha; + size = 4; + break; + + case PixelFormat_RGB24: + p[0] = red; + p[1] = green; + p[2] = blue; + size = 3; + break; + + default: + throw OrthancException(ErrorCode_NotImplemented); + } + + for (unsigned int y = 0; y < image.GetHeight(); y++) + { + uint8_t* q = reinterpret_cast(image.GetRow(y)); + + for (unsigned int x = 0; x < image.GetWidth(); x++) + { + for (unsigned int i = 0; i < size; i++) + { + q[i] = p[i]; + } + + q += size; + } + } + } + + void ImageProcessing::ShiftRight(ImageAccessor& image, unsigned int shift) { diff -r daf99382bc18 -r d850500b8ca6 Orthanc/Core/Images/ImageProcessing.h --- a/Orthanc/Core/Images/ImageProcessing.h Fri Sep 16 09:19:10 2016 +0200 +++ b/Orthanc/Core/Images/ImageProcessing.h Tue Nov 08 10:15:05 2016 +0100 @@ -50,6 +50,12 @@ static void Set(ImageAccessor& image, int64_t value); + static void Set(ImageAccessor& image, + uint8_t red, + uint8_t green, + uint8_t blue, + uint8_t alpha); + static void ShiftRight(ImageAccessor& target, unsigned int shift); diff -r daf99382bc18 -r d850500b8ca6 Orthanc/Core/MultiThreading/SharedMessageQueue.cpp --- a/Orthanc/Core/MultiThreading/SharedMessageQueue.cpp Fri Sep 16 09:19:10 2016 +0200 +++ b/Orthanc/Core/MultiThreading/SharedMessageQueue.cpp Tue Nov 08 10:15:05 2016 +0100 @@ -185,4 +185,24 @@ boost::mutex::scoped_lock lock(mutex_); isFifo_ = false; } + + void SharedMessageQueue::Clear() + { + boost::mutex::scoped_lock lock(mutex_); + + if (queue_.empty()) + { + return; + } + else + { + while (!queue_.empty()) + { + std::auto_ptr message(queue_.front()); + queue_.pop_front(); + } + + emptied_.notify_all(); + } + } } diff -r daf99382bc18 -r d850500b8ca6 Orthanc/Core/MultiThreading/SharedMessageQueue.h --- a/Orthanc/Core/MultiThreading/SharedMessageQueue.h Fri Sep 16 09:19:10 2016 +0200 +++ b/Orthanc/Core/MultiThreading/SharedMessageQueue.h Tue Nov 08 10:15:05 2016 +0100 @@ -78,5 +78,7 @@ void SetFifoPolicy(); void SetLifoPolicy(); + + void Clear(); }; } diff -r daf99382bc18 -r d850500b8ca6 Orthanc/Core/Toolbox.cpp --- a/Orthanc/Core/Toolbox.cpp Fri Sep 16 09:19:10 2016 +0200 +++ b/Orthanc/Core/Toolbox.cpp Tue Nov 08 10:15:05 2016 +0100 @@ -111,6 +111,18 @@ namespace Orthanc { + void Toolbox::USleep(uint64_t microSeconds) + { +#if defined(_WIN32) + ::Sleep(static_cast(microSeconds / static_cast(1000))); +#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) || defined(__native_client__) + usleep(microSeconds); +#else +#error Support your platform here +#endif + } + + #if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 static bool finish_; static ServerBarrierEvent barrierEvent_; @@ -135,18 +147,6 @@ #endif - void Toolbox::USleep(uint64_t microSeconds) - { -#if defined(_WIN32) - ::Sleep(static_cast(microSeconds / static_cast(1000))); -#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD_kernel__) || defined(__FreeBSD__) - usleep(microSeconds); -#else -#error Support your platform here -#endif - } - - static ServerBarrierEvent ServerBarrierInternal(const bool* stopFlag) { #if defined(_WIN32) @@ -312,7 +312,7 @@ const std::string& path) { boost::filesystem::ofstream f; - f.open(path, std::ofstream::binary); + f.open(path, std::ofstream::out | std::ofstream::binary); if (!f.good()) { throw OrthancException(ErrorCode_CannotWriteFile); @@ -321,6 +321,12 @@ if (size != 0) { f.write(reinterpret_cast(content), size); + + if (!f.good()) + { + f.close(); + throw OrthancException(ErrorCode_FileStorageCannotWrite); + } } f.close(); @@ -838,6 +844,23 @@ } + bool Toolbox::IsAsciiString(const void* data, + size_t size) + { + const uint8_t* p = reinterpret_cast(data); + + for (size_t i = 0; i < size; i++, p++) + { + if (*p > 127 || (*p != 0 && iscntrl(*p))) + { + return false; + } + } + + return true; + } + + std::string Toolbox::ConvertToAscii(const std::string& source) { std::string result; diff -r daf99382bc18 -r d850500b8ca6 Orthanc/Core/Toolbox.h --- a/Orthanc/Core/Toolbox.h Fri Sep 16 09:19:10 2016 +0200 +++ b/Orthanc/Core/Toolbox.h Tue Nov 08 10:15:05 2016 +0100 @@ -49,6 +49,8 @@ namespace Toolbox { + void USleep(uint64_t microSeconds); + #if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 ServerBarrierEvent ServerBarrier(const bool& stopFlag); @@ -88,10 +90,6 @@ #endif #if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 - void USleep(uint64_t microSeconds); -#endif - -#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 void RemoveFile(const std::string& path); #endif @@ -165,6 +163,9 @@ std::string ConvertFromUtf8(const std::string& source, Encoding targetEncoding); + bool IsAsciiString(const void* data, + size_t size); + std::string ConvertToAscii(const std::string& source); std::string StripSpaces(const std::string& source); diff -r daf99382bc18 -r d850500b8ca6 Orthanc/Resources/CMake/BoostConfiguration.cmake --- a/Orthanc/Resources/CMake/BoostConfiguration.cmake Fri Sep 16 09:19:10 2016 +0200 +++ b/Orthanc/Resources/CMake/BoostConfiguration.cmake Tue Nov 08 10:15:05 2016 +0100 @@ -210,7 +210,8 @@ ${BOOST_SOURCES_DIR} ) - source_group(ThirdParty\\Boost REGULAR_EXPRESSION ${BOOST_SOURCES_DIR}/.*) + source_group(ThirdParty\\boost REGULAR_EXPRESSION ${BOOST_SOURCES_DIR}/.*) + else() add_definitions( -DBOOST_HAS_LOCALE=1 diff -r daf99382bc18 -r d850500b8ca6 Orthanc/Resources/CMake/DownloadPackage.cmake --- a/Orthanc/Resources/CMake/DownloadPackage.cmake Fri Sep 16 09:19:10 2016 +0200 +++ b/Orthanc/Resources/CMake/DownloadPackage.cmake Tue Nov 08 10:15:05 2016 +0100 @@ -15,12 +15,18 @@ ## Setup the patch command-line tool ## -if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") - set(PATCH_EXECUTABLE ${CMAKE_SOURCE_DIR}/Resources/ThirdParty/patch/patch.exe) -else () - find_program(PATCH_EXECUTABLE patch) - if (${PATCH_EXECUTABLE} MATCHES "PATCH_EXECUTABLE-NOTFOUND") - message(FATAL_ERROR "Please install the 'patch' standard command-line tool") +if (NOT ORTHANC_DISABLE_PATCH) + if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") + set(PATCH_EXECUTABLE ${CMAKE_CURRENT_LIST_DIR}/../ThirdParty/patch/patch.exe) + if (NOT EXISTS ${PATCH_EXECUTABLE}) + message(FATAL_ERROR "Unable to find the patch.exe tool that is shipped with Orthanc") + endif() + + else () + find_program(PATCH_EXECUTABLE patch) + if (${PATCH_EXECUTABLE} MATCHES "PATCH_EXECUTABLE-NOTFOUND") + message(FATAL_ERROR "Please install the 'patch' standard command-line tool") + endif() endif() endif() diff -r daf99382bc18 -r d850500b8ca6 Orthanc/Resources/CMake/GoogleTestConfiguration.cmake --- a/Orthanc/Resources/CMake/GoogleTestConfiguration.cmake Fri Sep 16 09:19:10 2016 +0200 +++ b/Orthanc/Resources/CMake/GoogleTestConfiguration.cmake Tue Nov 08 10:15:05 2016 +0100 @@ -28,6 +28,8 @@ add_definitions(/D _VARIADIC_MAX=10) endif() + source_group(ThirdParty\\GoogleTest REGULAR_EXPRESSION ${GTEST_SOURCES_DIR}/.*) + else() include(FindGTest) if (NOT GTEST_FOUND) diff -r daf99382bc18 -r d850500b8ca6 Orthanc/Resources/ThirdParty/VisualStudio/stdint.h --- a/Orthanc/Resources/ThirdParty/VisualStudio/stdint.h Fri Sep 16 09:19:10 2016 +0200 +++ b/Orthanc/Resources/ThirdParty/VisualStudio/stdint.h Tue Nov 08 10:15:05 2016 +0100 @@ -1,247 +1,259 @@ -// ISO C9x compliant stdint.h for Microsoft Visual Studio -// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 -// -// Copyright (c) 2006-2008 Alexander Chemeris -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. The name of the author may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED -// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _MSC_VER // [ -#error "Use this header only with Microsoft Visual C++ compilers!" -#endif // _MSC_VER ] - -#ifndef _MSC_STDINT_H_ // [ -#define _MSC_STDINT_H_ - -#if _MSC_VER > 1000 -#pragma once -#endif - -#include - -// For Visual Studio 6 in C++ mode and for many Visual Studio versions when -// compiling for ARM we should wrap include with 'extern "C++" {}' -// or compiler give many errors like this: -// error C2733: second C linkage of overloaded function 'wmemchr' not allowed -#ifdef __cplusplus -extern "C" { -#endif -# include -#ifdef __cplusplus -} -#endif - -// Define _W64 macros to mark types changing their size, like intptr_t. -#ifndef _W64 -# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 -# define _W64 __w64 -# else -# define _W64 -# endif -#endif - - -// 7.18.1 Integer types - -// 7.18.1.1 Exact-width integer types - -// Visual Studio 6 and Embedded Visual C++ 4 doesn't -// realize that, e.g. char has the same size as __int8 -// so we give up on __intX for them. -#if (_MSC_VER < 1300) - typedef signed char int8_t; - typedef signed short int16_t; - typedef signed int int32_t; - typedef unsigned char uint8_t; - typedef unsigned short uint16_t; - typedef unsigned int uint32_t; -#else - typedef signed __int8 int8_t; - typedef signed __int16 int16_t; - typedef signed __int32 int32_t; - typedef unsigned __int8 uint8_t; - typedef unsigned __int16 uint16_t; - typedef unsigned __int32 uint32_t; -#endif -typedef signed __int64 int64_t; -typedef unsigned __int64 uint64_t; - - -// 7.18.1.2 Minimum-width integer types -typedef int8_t int_least8_t; -typedef int16_t int_least16_t; -typedef int32_t int_least32_t; -typedef int64_t int_least64_t; -typedef uint8_t uint_least8_t; -typedef uint16_t uint_least16_t; -typedef uint32_t uint_least32_t; -typedef uint64_t uint_least64_t; - -// 7.18.1.3 Fastest minimum-width integer types -typedef int8_t int_fast8_t; -typedef int16_t int_fast16_t; -typedef int32_t int_fast32_t; -typedef int64_t int_fast64_t; -typedef uint8_t uint_fast8_t; -typedef uint16_t uint_fast16_t; -typedef uint32_t uint_fast32_t; -typedef uint64_t uint_fast64_t; - -// 7.18.1.4 Integer types capable of holding object pointers -#ifdef _WIN64 // [ - typedef signed __int64 intptr_t; - typedef unsigned __int64 uintptr_t; -#else // _WIN64 ][ - typedef _W64 signed int intptr_t; - typedef _W64 unsigned int uintptr_t; -#endif // _WIN64 ] - -// 7.18.1.5 Greatest-width integer types -typedef int64_t intmax_t; -typedef uint64_t uintmax_t; - - -// 7.18.2 Limits of specified-width integer types - -#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 - -// 7.18.2.1 Limits of exact-width integer types -#define INT8_MIN ((int8_t)_I8_MIN) -#define INT8_MAX _I8_MAX -#define INT16_MIN ((int16_t)_I16_MIN) -#define INT16_MAX _I16_MAX -#define INT32_MIN ((int32_t)_I32_MIN) -#define INT32_MAX _I32_MAX -#define INT64_MIN ((int64_t)_I64_MIN) -#define INT64_MAX _I64_MAX -#define UINT8_MAX _UI8_MAX -#define UINT16_MAX _UI16_MAX -#define UINT32_MAX _UI32_MAX -#define UINT64_MAX _UI64_MAX - -// 7.18.2.2 Limits of minimum-width integer types -#define INT_LEAST8_MIN INT8_MIN -#define INT_LEAST8_MAX INT8_MAX -#define INT_LEAST16_MIN INT16_MIN -#define INT_LEAST16_MAX INT16_MAX -#define INT_LEAST32_MIN INT32_MIN -#define INT_LEAST32_MAX INT32_MAX -#define INT_LEAST64_MIN INT64_MIN -#define INT_LEAST64_MAX INT64_MAX -#define UINT_LEAST8_MAX UINT8_MAX -#define UINT_LEAST16_MAX UINT16_MAX -#define UINT_LEAST32_MAX UINT32_MAX -#define UINT_LEAST64_MAX UINT64_MAX - -// 7.18.2.3 Limits of fastest minimum-width integer types -#define INT_FAST8_MIN INT8_MIN -#define INT_FAST8_MAX INT8_MAX -#define INT_FAST16_MIN INT16_MIN -#define INT_FAST16_MAX INT16_MAX -#define INT_FAST32_MIN INT32_MIN -#define INT_FAST32_MAX INT32_MAX -#define INT_FAST64_MIN INT64_MIN -#define INT_FAST64_MAX INT64_MAX -#define UINT_FAST8_MAX UINT8_MAX -#define UINT_FAST16_MAX UINT16_MAX -#define UINT_FAST32_MAX UINT32_MAX -#define UINT_FAST64_MAX UINT64_MAX - -// 7.18.2.4 Limits of integer types capable of holding object pointers -#ifdef _WIN64 // [ -# define INTPTR_MIN INT64_MIN -# define INTPTR_MAX INT64_MAX -# define UINTPTR_MAX UINT64_MAX -#else // _WIN64 ][ -# define INTPTR_MIN INT32_MIN -# define INTPTR_MAX INT32_MAX -# define UINTPTR_MAX UINT32_MAX -#endif // _WIN64 ] - -// 7.18.2.5 Limits of greatest-width integer types -#define INTMAX_MIN INT64_MIN -#define INTMAX_MAX INT64_MAX -#define UINTMAX_MAX UINT64_MAX - -// 7.18.3 Limits of other integer types - -#ifdef _WIN64 // [ -# define PTRDIFF_MIN _I64_MIN -# define PTRDIFF_MAX _I64_MAX -#else // _WIN64 ][ -# define PTRDIFF_MIN _I32_MIN -# define PTRDIFF_MAX _I32_MAX -#endif // _WIN64 ] - -#define SIG_ATOMIC_MIN INT_MIN -#define SIG_ATOMIC_MAX INT_MAX - -#ifndef SIZE_MAX // [ -# ifdef _WIN64 // [ -# define SIZE_MAX _UI64_MAX -# else // _WIN64 ][ -# define SIZE_MAX _UI32_MAX -# endif // _WIN64 ] -#endif // SIZE_MAX ] - -// WCHAR_MIN and WCHAR_MAX are also defined in -#ifndef WCHAR_MIN // [ -# define WCHAR_MIN 0 -#endif // WCHAR_MIN ] -#ifndef WCHAR_MAX // [ -# define WCHAR_MAX _UI16_MAX -#endif // WCHAR_MAX ] - -#define WINT_MIN 0 -#define WINT_MAX _UI16_MAX - -#endif // __STDC_LIMIT_MACROS ] - - -// 7.18.4 Limits of other integer types - -#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 - -// 7.18.4.1 Macros for minimum-width integer constants - -#define INT8_C(val) val##i8 -#define INT16_C(val) val##i16 -#define INT32_C(val) val##i32 -#define INT64_C(val) val##i64 - -#define UINT8_C(val) val##ui8 -#define UINT16_C(val) val##ui16 -#define UINT32_C(val) val##ui32 -#define UINT64_C(val) val##ui64 - -// 7.18.4.2 Macros for greatest-width integer constants -#define INTMAX_C INT64_C -#define UINTMAX_C UINT64_C - -#endif // __STDC_CONSTANT_MACROS ] - - -#endif // _MSC_STDINT_H_ ] +// ISO C9x compliant stdint.h for Microsoft Visual Studio +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 +// +// Copyright (c) 2006-2013 Alexander Chemeris +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. Neither the name of the product nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _MSC_VER // [ +#error "Use this header only with Microsoft Visual C++ compilers!" +#endif // _MSC_VER ] + +#ifndef _MSC_STDINT_H_ // [ +#define _MSC_STDINT_H_ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#if _MSC_VER >= 1600 // [ +#include +#else // ] _MSC_VER >= 1600 [ + +#include + +// For Visual Studio 6 in C++ mode and for many Visual Studio versions when +// compiling for ARM we should wrap include with 'extern "C++" {}' +// or compiler give many errors like this: +// error C2733: second C linkage of overloaded function 'wmemchr' not allowed +#ifdef __cplusplus +extern "C" { +#endif +# include +#ifdef __cplusplus +} +#endif + +// Define _W64 macros to mark types changing their size, like intptr_t. +#ifndef _W64 +# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 +# define _W64 __w64 +# else +# define _W64 +# endif +#endif + + +// 7.18.1 Integer types + +// 7.18.1.1 Exact-width integer types + +// Visual Studio 6 and Embedded Visual C++ 4 doesn't +// realize that, e.g. char has the same size as __int8 +// so we give up on __intX for them. +#if (_MSC_VER < 1300) + typedef signed char int8_t; + typedef signed short int16_t; + typedef signed int int32_t; + typedef unsigned char uint8_t; + typedef unsigned short uint16_t; + typedef unsigned int uint32_t; +#else + typedef signed __int8 int8_t; + typedef signed __int16 int16_t; + typedef signed __int32 int32_t; + typedef unsigned __int8 uint8_t; + typedef unsigned __int16 uint16_t; + typedef unsigned __int32 uint32_t; +#endif +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; + + +// 7.18.1.2 Minimum-width integer types +typedef int8_t int_least8_t; +typedef int16_t int_least16_t; +typedef int32_t int_least32_t; +typedef int64_t int_least64_t; +typedef uint8_t uint_least8_t; +typedef uint16_t uint_least16_t; +typedef uint32_t uint_least32_t; +typedef uint64_t uint_least64_t; + +// 7.18.1.3 Fastest minimum-width integer types +typedef int8_t int_fast8_t; +typedef int16_t int_fast16_t; +typedef int32_t int_fast32_t; +typedef int64_t int_fast64_t; +typedef uint8_t uint_fast8_t; +typedef uint16_t uint_fast16_t; +typedef uint32_t uint_fast32_t; +typedef uint64_t uint_fast64_t; + +// 7.18.1.4 Integer types capable of holding object pointers +#ifdef _WIN64 // [ + typedef signed __int64 intptr_t; + typedef unsigned __int64 uintptr_t; +#else // _WIN64 ][ + typedef _W64 signed int intptr_t; + typedef _W64 unsigned int uintptr_t; +#endif // _WIN64 ] + +// 7.18.1.5 Greatest-width integer types +typedef int64_t intmax_t; +typedef uint64_t uintmax_t; + + +// 7.18.2 Limits of specified-width integer types + +#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 + +// 7.18.2.1 Limits of exact-width integer types +#define INT8_MIN ((int8_t)_I8_MIN) +#define INT8_MAX _I8_MAX +#define INT16_MIN ((int16_t)_I16_MIN) +#define INT16_MAX _I16_MAX +#define INT32_MIN ((int32_t)_I32_MIN) +#define INT32_MAX _I32_MAX +#define INT64_MIN ((int64_t)_I64_MIN) +#define INT64_MAX _I64_MAX +#define UINT8_MAX _UI8_MAX +#define UINT16_MAX _UI16_MAX +#define UINT32_MAX _UI32_MAX +#define UINT64_MAX _UI64_MAX + +// 7.18.2.2 Limits of minimum-width integer types +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST8_MAX INT8_MAX +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST16_MAX INT16_MAX +#define INT_LEAST32_MIN INT32_MIN +#define INT_LEAST32_MAX INT32_MAX +#define INT_LEAST64_MIN INT64_MIN +#define INT_LEAST64_MAX INT64_MAX +#define UINT_LEAST8_MAX UINT8_MAX +#define UINT_LEAST16_MAX UINT16_MAX +#define UINT_LEAST32_MAX UINT32_MAX +#define UINT_LEAST64_MAX UINT64_MAX + +// 7.18.2.3 Limits of fastest minimum-width integer types +#define INT_FAST8_MIN INT8_MIN +#define INT_FAST8_MAX INT8_MAX +#define INT_FAST16_MIN INT16_MIN +#define INT_FAST16_MAX INT16_MAX +#define INT_FAST32_MIN INT32_MIN +#define INT_FAST32_MAX INT32_MAX +#define INT_FAST64_MIN INT64_MIN +#define INT_FAST64_MAX INT64_MAX +#define UINT_FAST8_MAX UINT8_MAX +#define UINT_FAST16_MAX UINT16_MAX +#define UINT_FAST32_MAX UINT32_MAX +#define UINT_FAST64_MAX UINT64_MAX + +// 7.18.2.4 Limits of integer types capable of holding object pointers +#ifdef _WIN64 // [ +# define INTPTR_MIN INT64_MIN +# define INTPTR_MAX INT64_MAX +# define UINTPTR_MAX UINT64_MAX +#else // _WIN64 ][ +# define INTPTR_MIN INT32_MIN +# define INTPTR_MAX INT32_MAX +# define UINTPTR_MAX UINT32_MAX +#endif // _WIN64 ] + +// 7.18.2.5 Limits of greatest-width integer types +#define INTMAX_MIN INT64_MIN +#define INTMAX_MAX INT64_MAX +#define UINTMAX_MAX UINT64_MAX + +// 7.18.3 Limits of other integer types + +#ifdef _WIN64 // [ +# define PTRDIFF_MIN _I64_MIN +# define PTRDIFF_MAX _I64_MAX +#else // _WIN64 ][ +# define PTRDIFF_MIN _I32_MIN +# define PTRDIFF_MAX _I32_MAX +#endif // _WIN64 ] + +#define SIG_ATOMIC_MIN INT_MIN +#define SIG_ATOMIC_MAX INT_MAX + +#ifndef SIZE_MAX // [ +# ifdef _WIN64 // [ +# define SIZE_MAX _UI64_MAX +# else // _WIN64 ][ +# define SIZE_MAX _UI32_MAX +# endif // _WIN64 ] +#endif // SIZE_MAX ] + +// WCHAR_MIN and WCHAR_MAX are also defined in +#ifndef WCHAR_MIN // [ +# define WCHAR_MIN 0 +#endif // WCHAR_MIN ] +#ifndef WCHAR_MAX // [ +# define WCHAR_MAX _UI16_MAX +#endif // WCHAR_MAX ] + +#define WINT_MIN 0 +#define WINT_MAX _UI16_MAX + +#endif // __STDC_LIMIT_MACROS ] + + +// 7.18.4 Limits of other integer types + +#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 + +// 7.18.4.1 Macros for minimum-width integer constants + +#define INT8_C(val) val##i8 +#define INT16_C(val) val##i16 +#define INT32_C(val) val##i32 +#define INT64_C(val) val##i64 + +#define UINT8_C(val) val##ui8 +#define UINT16_C(val) val##ui16 +#define UINT32_C(val) val##ui32 +#define UINT64_C(val) val##ui64 + +// 7.18.4.2 Macros for greatest-width integer constants +// These #ifndef's are needed to prevent collisions with . +// Check out Issue 9 for the details. +#ifndef INTMAX_C // [ +# define INTMAX_C INT64_C +#endif // INTMAX_C ] +#ifndef UINTMAX_C // [ +# define UINTMAX_C UINT64_C +#endif // UINTMAX_C ] + +#endif // __STDC_CONSTANT_MACROS ] + +#endif // _MSC_VER >= 1600 ] + +#endif // _MSC_STDINT_H_ ] diff -r daf99382bc18 -r d850500b8ca6 Orthanc/Resources/ThirdParty/base64/base64.cpp --- a/Orthanc/Resources/ThirdParty/base64/base64.cpp Fri Sep 16 09:19:10 2016 +0200 +++ b/Orthanc/Resources/ThirdParty/base64/base64.cpp Tue Nov 08 10:15:05 2016 +0100 @@ -1,128 +1,128 @@ -/* - base64.cpp and base64.h - - Copyright (C) 2004-2008 René Nyffenegger - - This source code is provided 'as-is', without any express or implied - warranty. In no event will the author be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this source code must not be misrepresented; you must not - claim that you wrote the original source code. If you use this source code - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original source code. - - 3. This notice may not be removed or altered from any source distribution. - - René Nyffenegger rene.nyffenegger@adp-gmbh.ch - -*/ - -#include "base64.h" -#include - -static const std::string base64_chars = - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789+/"; - - -static inline bool is_base64(unsigned char c) { - return (isalnum(c) || (c == '+') || (c == '/')); -} - -std::string base64_encode(const std::string& stringToEncode) -{ - const unsigned char* bytes_to_encode = reinterpret_cast - (stringToEncode.size() > 0 ? &stringToEncode[0] : NULL); - unsigned int in_len = stringToEncode.size(); - - std::string ret; - int i = 0; - int j = 0; - unsigned char char_array_3[3]; - unsigned char char_array_4[4]; - - while (in_len--) { - char_array_3[i++] = *(bytes_to_encode++); - if (i == 3) { - char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; - char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); - char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); - char_array_4[3] = char_array_3[2] & 0x3f; - - for(i = 0; (i <4) ; i++) - ret += base64_chars[char_array_4[i]]; - i = 0; - } - } - - if (i) - { - for(j = i; j < 3; j++) - char_array_3[j] = '\0'; - - char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; - char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); - char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); - char_array_4[3] = char_array_3[2] & 0x3f; - - for (j = 0; (j < i + 1); j++) - ret += base64_chars[char_array_4[j]]; - - while((i++ < 3)) - ret += '='; - - } - - return ret; -} - - -std::string base64_decode(const std::string& encoded_string) { - int in_len = encoded_string.size(); - int i = 0; - int j = 0; - int in_ = 0; - unsigned char char_array_4[4], char_array_3[3]; - std::string ret; - - while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) { - char_array_4[i++] = encoded_string[in_]; in_++; - if (i ==4) { - for (i = 0; i <4; i++) - char_array_4[i] = base64_chars.find(char_array_4[i]); - - char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); - char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); - char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; - - for (i = 0; (i < 3); i++) - ret += char_array_3[i]; - i = 0; - } - } - - if (i) { - for (j = i; j <4; j++) - char_array_4[j] = 0; - - for (j = 0; j <4; j++) - char_array_4[j] = base64_chars.find(char_array_4[j]); - - char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); - char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); - char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; - - for (j = 0; (j < i - 1); j++) ret += char_array_3[j]; - } - - return ret; -} +/* + base64.cpp and base64.h + + Copyright (C) 2004-2008 René Nyffenegger + + This source code is provided 'as-is', without any express or implied + warranty. In no event will the author be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this source code must not be misrepresented; you must not + claim that you wrote the original source code. If you use this source code + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original source code. + + 3. This notice may not be removed or altered from any source distribution. + + René Nyffenegger rene.nyffenegger@adp-gmbh.ch + +*/ + +#include "base64.h" +#include + +static const std::string base64_chars = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789+/"; + + +static inline bool is_base64(unsigned char c) { + return (isalnum(c) || (c == '+') || (c == '/')); +} + +std::string base64_encode(const std::string& stringToEncode) +{ + const unsigned char* bytes_to_encode = reinterpret_cast + (stringToEncode.size() > 0 ? &stringToEncode[0] : NULL); + unsigned int in_len = stringToEncode.size(); + + std::string ret; + int i = 0; + int j = 0; + unsigned char char_array_3[3]; + unsigned char char_array_4[4]; + + while (in_len--) { + char_array_3[i++] = *(bytes_to_encode++); + if (i == 3) { + char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; + char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); + char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); + char_array_4[3] = char_array_3[2] & 0x3f; + + for(i = 0; (i <4) ; i++) + ret += base64_chars[char_array_4[i]]; + i = 0; + } + } + + if (i) + { + for(j = i; j < 3; j++) + char_array_3[j] = '\0'; + + char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; + char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); + char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); + char_array_4[3] = char_array_3[2] & 0x3f; + + for (j = 0; (j < i + 1); j++) + ret += base64_chars[char_array_4[j]]; + + while((i++ < 3)) + ret += '='; + + } + + return ret; +} + + +std::string base64_decode(const std::string& encoded_string) { + int in_len = encoded_string.size(); + int i = 0; + int j = 0; + int in_ = 0; + unsigned char char_array_4[4], char_array_3[3]; + std::string ret; + + while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) { + char_array_4[i++] = encoded_string[in_]; in_++; + if (i ==4) { + for (i = 0; i <4; i++) + char_array_4[i] = base64_chars.find(char_array_4[i]); + + char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); + char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); + char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; + + for (i = 0; (i < 3); i++) + ret += char_array_3[i]; + i = 0; + } + } + + if (i) { + for (j = i; j <4; j++) + char_array_4[j] = 0; + + for (j = 0; j <4; j++) + char_array_4[j] = base64_chars.find(char_array_4[j]); + + char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); + char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); + char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; + + for (j = 0; (j < i - 1); j++) ret += char_array_3[j]; + } + + return ret; +} diff -r daf99382bc18 -r d850500b8ca6 Orthanc/Resources/ThirdParty/base64/base64.h --- a/Orthanc/Resources/ThirdParty/base64/base64.h Fri Sep 16 09:19:10 2016 +0200 +++ b/Orthanc/Resources/ThirdParty/base64/base64.h Tue Nov 08 10:15:05 2016 +0100 @@ -1,4 +1,4 @@ -#include - -std::string base64_encode(const std::string& stringToEncode); -std::string base64_decode(const std::string& s); +#include + +std::string base64_encode(const std::string& stringToEncode); +std::string base64_decode(const std::string& s); diff -r daf99382bc18 -r d850500b8ca6 Plugin/DecodedImageAdapter.cpp --- a/Plugin/DecodedImageAdapter.cpp Fri Sep 16 09:19:10 2016 +0200 +++ b/Plugin/DecodedImageAdapter.cpp Tue Nov 08 10:15:05 2016 +0100 @@ -284,8 +284,7 @@ accessor.AssignReadOnly(OrthancPlugins::Convert(image.GetFormat()), image.GetWidth(), image.GetHeight(), image.GetPitch(), image.GetBuffer()); - Orthanc::ImageBuffer buffer; - buffer.SetMinimalPitchForced(true); + std::auto_ptr buffer; Orthanc::ImageAccessor converted; @@ -297,10 +296,11 @@ case Orthanc::PixelFormat_Grayscale8: case Orthanc::PixelFormat_Grayscale16: - buffer.SetFormat(Orthanc::PixelFormat_Grayscale16); - buffer.SetWidth(accessor.GetWidth()); - buffer.SetHeight(accessor.GetHeight()); - converted = buffer.GetAccessor(); + buffer.reset(new Orthanc::ImageBuffer(Orthanc::PixelFormat_Grayscale16, + accessor.GetWidth(), + accessor.GetHeight(), + true /* force minimal pitch */)); + converted = buffer->GetAccessor(); Orthanc::ImageProcessing::Convert(converted, accessor); break; @@ -386,8 +386,7 @@ accessor.AssignReadOnly(OrthancPlugins::Convert(image.GetFormat()), image.GetWidth(), image.GetHeight(), image.GetPitch(), image.GetBuffer()); - Orthanc::ImageBuffer buffer; - buffer.SetMinimalPitchForced(true); + std::auto_ptr buffer; Orthanc::ImageAccessor converted; @@ -401,10 +400,12 @@ accessor.GetFormat() == Orthanc::PixelFormat_SignedGrayscale16) { result["Orthanc"]["Stretched"] = true; - buffer.SetFormat(Orthanc::PixelFormat_Grayscale8); - buffer.SetWidth(accessor.GetWidth()); - buffer.SetHeight(accessor.GetHeight()); - converted = buffer.GetAccessor(); + + buffer.reset(new Orthanc::ImageBuffer(Orthanc::PixelFormat_Grayscale8, + accessor.GetWidth(), + accessor.GetHeight(), + true /* force minimal pitch */)); + converted = buffer->GetAccessor(); int64_t a, b; Orthanc::ImageProcessing::GetMinMaxValue(a, b, accessor);