# HG changeset patch # User Sebastien Jodogne # Date 1448642425 -3600 # Node ID 2faa2abbf3118359c68c9f7cd9d50fa9b77ae07c # Parent 323dd64029335532bb50be1426743501c012e86f refactoring diff -r 323dd6402933 -r 2faa2abbf311 Plugins/Samples/GdcmDecoder/GdcmDecoderCache.cpp --- a/Plugins/Samples/GdcmDecoder/GdcmDecoderCache.cpp Fri Nov 27 12:54:54 2015 +0100 +++ b/Plugins/Samples/GdcmDecoder/GdcmDecoderCache.cpp Fri Nov 27 17:40:25 2015 +0100 @@ -83,7 +83,7 @@ // This is not the same image std::auto_ptr decoder(new GdcmImageDecoder(dicom, size)); - OrthancImageWrapper image(context, decoder->Decode(context, frameIndex)); + OrthancImageWrapper image(context, *decoder, frameIndex); { // Cache the newly created decoder for further use diff -r 323dd6402933 -r 2faa2abbf311 Plugins/Samples/GdcmDecoder/GdcmImageDecoder.cpp --- a/Plugins/Samples/GdcmDecoder/GdcmImageDecoder.cpp Fri Nov 27 12:54:54 2015 +0100 +++ b/Plugins/Samples/GdcmDecoder/GdcmImageDecoder.cpp Fri Nov 27 17:40:25 2015 +0100 @@ -222,6 +222,30 @@ } + double GdcmImageDecoder::GetSlope() const + { + return pimpl_->GetImage().GetSlope(); + } + + + double GdcmImageDecoder::GetIntercept() const + { + return pimpl_->GetImage().GetIntercept(); + } + + + double GdcmImageDecoder::GetColumnPixelSpacing() const + { + return pimpl_->GetImage().GetSpacing(1); + } + + + double GdcmImageDecoder::GetRowPixelSpacing() const + { + return pimpl_->GetImage().GetSpacing(0); + } + + size_t GdcmImageDecoder::GetBytesPerPixel(OrthancPluginPixelFormat format) { switch (format) diff -r 323dd6402933 -r 2faa2abbf311 Plugins/Samples/GdcmDecoder/GdcmImageDecoder.h --- a/Plugins/Samples/GdcmDecoder/GdcmImageDecoder.h Fri Nov 27 12:54:54 2015 +0100 +++ b/Plugins/Samples/GdcmDecoder/GdcmImageDecoder.h Fri Nov 27 17:40:25 2015 +0100 @@ -45,6 +45,14 @@ unsigned int GetFramesCount() const; + double GetSlope() const; + + double GetIntercept() const; + + double GetColumnPixelSpacing() const; + + double GetRowPixelSpacing() const; + static size_t GetBytesPerPixel(OrthancPluginPixelFormat format); OrthancPluginImage* Decode(OrthancPluginContext* context, diff -r 323dd6402933 -r 2faa2abbf311 Plugins/Samples/GdcmDecoder/OrthancImageWrapper.cpp --- a/Plugins/Samples/GdcmDecoder/OrthancImageWrapper.cpp Fri Nov 27 12:54:54 2015 +0100 +++ b/Plugins/Samples/GdcmDecoder/OrthancImageWrapper.cpp Fri Nov 27 17:40:25 2015 +0100 @@ -28,7 +28,11 @@ OrthancPluginPixelFormat format, uint32_t width, uint32_t height) : - context_(context) + context_(context), + slope_(1), + intercept_(0), + rowPixelSpacing_(1), + columnPixelSpacing_(1) { image_ = OrthancPluginCreateImage(context_, format, width, height); if (image_ == NULL) @@ -38,6 +42,20 @@ } + OrthancImageWrapper::OrthancImageWrapper(OrthancPluginContext* context, + GdcmImageDecoder& decoder, + unsigned int frameIndex) : + context_(context), + image_(decoder.Decode(context, frameIndex)), + slope_(decoder.GetSlope()), + intercept_(decoder.GetIntercept()), + rowPixelSpacing_(decoder.GetRowPixelSpacing()), + columnPixelSpacing_(decoder.GetColumnPixelSpacing()) + { + } + + + OrthancImageWrapper::~OrthancImageWrapper() { if (image_ != NULL) diff -r 323dd6402933 -r 2faa2abbf311 Plugins/Samples/GdcmDecoder/OrthancImageWrapper.h --- a/Plugins/Samples/GdcmDecoder/OrthancImageWrapper.h Fri Nov 27 12:54:54 2015 +0100 +++ b/Plugins/Samples/GdcmDecoder/OrthancImageWrapper.h Fri Nov 27 17:40:25 2015 +0100 @@ -22,6 +22,8 @@ #include +#include "GdcmImageDecoder.h" + namespace OrthancPlugins { class OrthancImageWrapper @@ -29,6 +31,10 @@ private: OrthancPluginContext* context_; OrthancPluginImage* image_; + double slope_; + double intercept_; + double rowPixelSpacing_; + double columnPixelSpacing_; public: OrthancImageWrapper(OrthancPluginContext* context, @@ -36,13 +42,9 @@ uint32_t width, uint32_t height); - // Takes the ownership OrthancImageWrapper(OrthancPluginContext* context, - OrthancPluginImage* image) : - context_(context), - image_(image) - { - } + GdcmImageDecoder& decoder, + unsigned int frameIndex); ~OrthancImageWrapper();