# HG changeset patch # User Sebastien Jodogne # Date 1542275072 -3600 # Node ID 88c79f1537ded605503ecc26439949991fb8ff0b # Parent 70823cb5ec9ee56d2e8e726fc924951adb1e8608 compatibility of captain branch with framework 1.4.2 diff -r 70823cb5ec9e -r 88c79f1537de Framework/Volumes/ImageBuffer3D.cpp --- a/Framework/Volumes/ImageBuffer3D.cpp Mon Nov 05 08:55:04 2018 +0100 +++ b/Framework/Volumes/ImageBuffer3D.cpp Thu Nov 15 10:44:32 2018 +0100 @@ -363,7 +363,11 @@ case VolumeProjection_Sagittal: sagittal_.reset(that.ExtractSagittalSlice(slice)); - sagittal_->GetReadOnlyAccessor(accessor_); + accessor_.AssignReadOnly(sagittal_->GetFormat(), + sagittal_->GetWidth(), + sagittal_->GetHeight(), + sagittal_->GetPitch(), + sagittal_->GetBuffer()); break; default: @@ -407,7 +411,11 @@ case VolumeProjection_Sagittal: sagittal_.reset(that.ExtractSagittalSlice(slice)); - sagittal_->GetWriteableAccessor(accessor_); + accessor_.AssignWritable(sagittal_->GetFormat(), + sagittal_->GetWidth(), + sagittal_->GetHeight(), + sagittal_->GetPitch(), + sagittal_->GetBuffer()); break; default: diff -r 70823cb5ec9e -r 88c79f1537de Framework/Widgets/LayoutWidget.cpp --- a/Framework/Widgets/LayoutWidget.cpp Mon Nov 05 08:55:04 2018 +0100 +++ b/Framework/Widgets/LayoutWidget.cpp Thu Nov 15 10:44:32 2018 +0100 @@ -28,6 +28,46 @@ namespace OrthancStone { + // This is a compatibility reimplementation of + // "ImageAcessor::GetRegion()" to use Orthanc <= 1.4.2 together with + // Stone. + static void GetRegionCompatibility(Orthanc::ImageAccessor& target, + const Orthanc::ImageAccessor& source, + unsigned int x, + unsigned int y, + unsigned int width, + unsigned int height) + { + if (x + width > source.GetWidth() || + y + height > source.GetHeight()) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); + } + + if (width == 0 || + height == 0) + { + target.AssignWritable(source.GetFormat(), 0, 0, 0, NULL); + } + else if (source.IsReadOnly()) + { + const uint8_t* p = (reinterpret_cast(source.GetBuffer()) + + y * source.GetPitch() + + x * source.GetBytesPerPixel()); + + target.AssignReadOnly(source.GetFormat(), width, height, source.GetPitch(), p); + } + else + { + uint8_t* p = (reinterpret_cast(source.GetBuffer()) + + y * source.GetPitch() + + x * source.GetBytesPerPixel()); + + target.AssignWritable(source.GetFormat(), width, height, source.GetPitch(), p); + } + } + + class LayoutWidget::LayoutMouseTracker : public IMouseTracker { private: @@ -36,7 +76,7 @@ int top_; unsigned int width_; unsigned int height_; - + public: LayoutMouseTracker(IMouseTracker* tracker, int left, @@ -58,7 +98,7 @@ virtual void Render(Orthanc::ImageAccessor& surface) { Orthanc::ImageAccessor accessor; - surface.GetRegion(accessor, left_, top_, width_, height_); + GetRegionCompatibility(accessor, surface, left_, top_, width_, height_); tracker_->Render(accessor); } @@ -144,7 +184,7 @@ else { Orthanc::ImageAccessor accessor; - target.GetRegion(accessor, left_, top_, width_, height_); + GetRegionCompatibility(accessor, target, left_, top_, width_, height_); return widget_->Render(accessor); } } @@ -176,7 +216,7 @@ if (Contains(x, y)) { Orthanc::ImageAccessor accessor; - target.GetRegion(accessor, left_, top_, width_, height_); + GetRegionCompatibility(accessor, target, left_, top_, width_, height_); widget_->RenderMouseOver(accessor, x - left_, y - top_); }