# HG changeset patch # User Sebastien Jodogne # Date 1538995527 -7200 # Node ID ce48c3b3b0e997a47207e8b8ea41ae263037ec10 # Parent 348e00b837b9b92848ccf77f666ec4e24477a18c fix for new ImageAccessor API diff -r 348e00b837b9 -r ce48c3b3b0e9 Applications/Samples/SingleVolumeApplication.h --- a/Applications/Samples/SingleVolumeApplication.h Mon Oct 01 10:46:26 2018 +0200 +++ b/Applications/Samples/SingleVolumeApplication.h Mon Oct 08 12:45:27 2018 +0200 @@ -174,7 +174,7 @@ std::auto_ptr widget(new LayerWidget); -#if 0 +#if 1 std::auto_ptr volume(new OrthancVolumeImage(context.GetWebService(), true)); if (series.empty()) { @@ -190,6 +190,15 @@ context.AddInteractor(new Interactor(*volume, *widget, projection, 0)); context.AddSlicedVolume(volume.release()); + if (1) + { + RenderStyle s; + //s.drawGrid_ = true; + s.alpha_ = 1; + s.windowing_ = ImageWindowing_Bone; + widget->SetLayerStyle(0, s); + } + else { RenderStyle s; s.alpha_ = 1; diff -r 348e00b837b9 -r ce48c3b3b0e9 Applications/Sdl/SdlCairoSurface.cpp --- a/Applications/Sdl/SdlCairoSurface.cpp Mon Oct 01 10:46:26 2018 +0200 +++ b/Applications/Sdl/SdlCairoSurface.cpp Mon Oct 08 12:45:27 2018 +0200 @@ -81,7 +81,8 @@ throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); } - Orthanc::ImageAccessor target = cairoSurface_->GetAccessor(); + Orthanc::ImageAccessor target; + cairoSurface_->GetWriteableAccessor(target); if (viewport.Render(target)) { diff -r 348e00b837b9 -r ce48c3b3b0e9 Framework/Layers/ColorFrameRenderer.cpp --- a/Framework/Layers/ColorFrameRenderer.cpp Mon Oct 01 10:46:26 2018 +0200 +++ b/Framework/Layers/ColorFrameRenderer.cpp Mon Oct 08 12:45:27 2018 +0200 @@ -30,7 +30,9 @@ { std::auto_ptr display(new CairoSurface(frame_->GetWidth(), frame_->GetHeight())); - Orthanc::ImageAccessor target = display->GetAccessor(); + Orthanc::ImageAccessor target; + display->GetWriteableAccessor(target); + Orthanc::ImageProcessing::Convert(target, *frame_); return display.release(); diff -r 348e00b837b9 -r ce48c3b3b0e9 Framework/Layers/GrayscaleFrameRenderer.cpp --- a/Framework/Layers/GrayscaleFrameRenderer.cpp Mon Oct 01 10:46:26 2018 +0200 +++ b/Framework/Layers/GrayscaleFrameRenderer.cpp Mon Oct 08 12:45:27 2018 +0200 @@ -52,7 +52,9 @@ lut = reinterpret_cast(Orthanc::EmbeddedResources::GetFileResourceBuffer(style.lut_)); } - Orthanc::ImageAccessor target = result->GetAccessor(); + Orthanc::ImageAccessor target; + result->GetWriteableAccessor(target); + const unsigned int width = target.GetWidth(); const unsigned int height = target.GetHeight(); diff -r 348e00b837b9 -r ce48c3b3b0e9 Framework/Toolbox/OrthancSlicesLoader.cpp --- a/Framework/Toolbox/OrthancSlicesLoader.cpp Mon Oct 01 10:46:26 2018 +0200 +++ b/Framework/Toolbox/OrthancSlicesLoader.cpp Mon Oct 08 12:45:27 2018 +0200 @@ -626,9 +626,7 @@ } - class StringImage : - public Orthanc::ImageAccessor, - public boost::noncopyable + class StringImage : public Orthanc::ImageAccessor { private: std::string buffer_; diff -r 348e00b837b9 -r ce48c3b3b0e9 Framework/Viewport/CairoSurface.cpp --- a/Framework/Viewport/CairoSurface.cpp Mon Oct 01 10:46:26 2018 +0200 +++ b/Framework/Viewport/CairoSurface.cpp Mon Oct 08 12:45:27 2018 +0200 @@ -105,24 +105,22 @@ void CairoSurface::Copy(const CairoSurface& other) { - Orthanc::ImageAccessor source = other.GetConstAccessor(); - Orthanc::ImageAccessor target = GetAccessor(); + Orthanc::ImageAccessor source, target; + other.GetReadOnlyAccessor(source); + GetWriteableAccessor(target); + Orthanc::ImageProcessing::Copy(target, source); } - Orthanc::ImageAccessor CairoSurface::GetConstAccessor() const + void CairoSurface::GetReadOnlyAccessor(Orthanc::ImageAccessor& target) const { - Orthanc::ImageAccessor accessor; - accessor.AssignReadOnly(Orthanc::PixelFormat_BGRA32, width_, height_, pitch_, buffer_); - return accessor; + target.AssignReadOnly(Orthanc::PixelFormat_BGRA32, width_, height_, pitch_, buffer_); } + - - Orthanc::ImageAccessor CairoSurface::GetAccessor() + void CairoSurface::GetWriteableAccessor(Orthanc::ImageAccessor& target) { - Orthanc::ImageAccessor accessor; - accessor.AssignWritable(Orthanc::PixelFormat_BGRA32, width_, height_, pitch_, buffer_); - return accessor; + target.AssignWritable(Orthanc::PixelFormat_BGRA32, width_, height_, pitch_, buffer_); } } diff -r 348e00b837b9 -r ce48c3b3b0e9 Framework/Viewport/CairoSurface.h --- a/Framework/Viewport/CairoSurface.h Mon Oct 01 10:46:26 2018 +0200 +++ b/Framework/Viewport/CairoSurface.h Mon Oct 08 12:45:27 2018 +0200 @@ -98,8 +98,8 @@ return surface_; } - Orthanc::ImageAccessor GetConstAccessor() const; + void GetReadOnlyAccessor(Orthanc::ImageAccessor& target) const; - Orthanc::ImageAccessor GetAccessor(); + void GetWriteableAccessor(Orthanc::ImageAccessor& target); }; } diff -r 348e00b837b9 -r ce48c3b3b0e9 Framework/Viewport/WidgetViewport.cpp --- a/Framework/Viewport/WidgetViewport.cpp Mon Oct 01 10:46:26 2018 +0200 +++ b/Framework/Viewport/WidgetViewport.cpp Mon Oct 08 12:45:27 2018 +0200 @@ -107,8 +107,9 @@ { return false; } - - Orthanc::ImageAccessor background = background_.GetAccessor(); + + Orthanc::ImageAccessor background; + background_.GetWriteableAccessor(background); if (backgroundChanged_ && !centralWidget_->Render(background)) diff -r 348e00b837b9 -r ce48c3b3b0e9 Framework/Volumes/ImageBuffer3D.cpp --- a/Framework/Volumes/ImageBuffer3D.cpp Mon Oct 01 10:46:26 2018 +0200 +++ b/Framework/Volumes/ImageBuffer3D.cpp Mon Oct 08 12:45:27 2018 +0200 @@ -29,53 +29,47 @@ namespace OrthancStone { - Orthanc::ImageAccessor ImageBuffer3D::GetAxialSliceAccessor(unsigned int slice, - bool readOnly) const + void ImageBuffer3D::GetAxialSliceAccessor(Orthanc::ImageAccessor& target, + unsigned int slice, + bool readOnly) const { if (slice >= depth_) { throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); } - Orthanc::ImageAccessor accessor; - if (readOnly) { - accessor.AssignReadOnly(format_, width_, height_, image_.GetPitch(), - image_.GetConstRow(height_ * (depth_ - 1 - slice))); + target.AssignReadOnly(format_, width_, height_, image_.GetPitch(), + image_.GetConstRow(height_ * (depth_ - 1 - slice))); } else { - accessor.AssignWritable(format_, width_, height_, image_.GetPitch(), - image_.GetRow(height_ * (depth_ - 1 - slice))); + target.AssignWritable(format_, width_, height_, image_.GetPitch(), + image_.GetRow(height_ * (depth_ - 1 - slice))); } - - return accessor; } - Orthanc::ImageAccessor ImageBuffer3D::GetCoronalSliceAccessor(unsigned int slice, - bool readOnly) const + void ImageBuffer3D::GetCoronalSliceAccessor(Orthanc::ImageAccessor& target, + unsigned int slice, + bool readOnly) const { if (slice >= height_) { throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); } - Orthanc::ImageAccessor accessor; - if (readOnly) { - accessor.AssignReadOnly(format_, width_, depth_, image_.GetPitch() * height_, - image_.GetConstRow(slice)); + target.AssignReadOnly(format_, width_, depth_, image_.GetPitch() * height_, + image_.GetConstRow(slice)); } else { - accessor.AssignWritable(format_, width_, depth_, image_.GetPitch() * height_, - image_.GetRow(slice)); + target.AssignWritable(format_, width_, depth_, image_.GetPitch() * height_, + image_.GetRow(slice)); } - - return accessor; } @@ -360,16 +354,16 @@ switch (projection) { case VolumeProjection_Axial: - accessor_ = that.GetAxialSliceAccessor(slice, true); + that.GetAxialSliceAccessor(accessor_, slice, true); break; case VolumeProjection_Coronal: - accessor_ = that.GetCoronalSliceAccessor(slice, true); + that.GetCoronalSliceAccessor(accessor_, slice, true); break; case VolumeProjection_Sagittal: sagittal_.reset(that.ExtractSagittalSlice(slice)); - accessor_ = *sagittal_; + sagittal_->GetReadOnlyAccessor(accessor_); break; default: @@ -404,16 +398,16 @@ switch (projection) { case VolumeProjection_Axial: - accessor_ = that.GetAxialSliceAccessor(slice, false); + that.GetAxialSliceAccessor(accessor_, slice, false); break; case VolumeProjection_Coronal: - accessor_ = that.GetCoronalSliceAccessor(slice, false); + that.GetCoronalSliceAccessor(accessor_, slice, false); break; case VolumeProjection_Sagittal: sagittal_.reset(that.ExtractSagittalSlice(slice)); - accessor_ = *sagittal_; + sagittal_->GetWriteableAccessor(accessor_); break; default: diff -r 348e00b837b9 -r ce48c3b3b0e9 Framework/Volumes/ImageBuffer3D.h --- a/Framework/Volumes/ImageBuffer3D.h Mon Oct 01 10:46:26 2018 +0200 +++ b/Framework/Volumes/ImageBuffer3D.h Mon Oct 08 12:45:27 2018 +0200 @@ -48,11 +48,13 @@ void ExtendImageRange(const Orthanc::ImageAccessor& slice); - Orthanc::ImageAccessor GetAxialSliceAccessor(unsigned int slice, - bool readOnly) const; - - Orthanc::ImageAccessor GetCoronalSliceAccessor(unsigned int slice, - bool readOnly) const; + void GetAxialSliceAccessor(Orthanc::ImageAccessor& target, + unsigned int slice, + bool readOnly) const; + + void GetCoronalSliceAccessor(Orthanc::ImageAccessor& target, + unsigned int slice, + bool readOnly) const; Orthanc::Image* ExtractSagittalSlice(unsigned int slice) const; diff -r 348e00b837b9 -r ce48c3b3b0e9 Framework/Widgets/CairoWidget.cpp --- a/Framework/Widgets/CairoWidget.cpp Mon Oct 01 10:46:26 2018 +0200 +++ b/Framework/Widgets/CairoWidget.cpp Mon Oct 08 12:45:27 2018 +0200 @@ -59,7 +59,9 @@ if (RenderCairo(context)) { - Orthanc::ImageProcessing::Copy(target, surface_.GetAccessor()); + Orthanc::ImageAccessor surface; + surface_.GetReadOnlyAccessor(surface); + Orthanc::ImageProcessing::Copy(target, surface); return true; } else @@ -82,7 +84,8 @@ } else { - Orthanc::ImageAccessor accessor = surface_.GetAccessor(); + Orthanc::ImageAccessor accessor; + surface_.GetWriteableAccessor(accessor); Orthanc::ImageProcessing::Copy(accessor, target); CairoContext context(surface_); diff -r 348e00b837b9 -r ce48c3b3b0e9 Framework/Widgets/LayoutWidget.cpp --- a/Framework/Widgets/LayoutWidget.cpp Mon Oct 01 10:46:26 2018 +0200 +++ b/Framework/Widgets/LayoutWidget.cpp Mon Oct 08 12:45:27 2018 +0200 @@ -57,7 +57,8 @@ virtual void Render(Orthanc::ImageAccessor& surface) { - Orthanc::ImageAccessor accessor = surface.GetRegion(left_, top_, width_, height_); + Orthanc::ImageAccessor accessor; + surface.GetRegion(accessor, left_, top_, width_, height_); tracker_->Render(accessor); } @@ -142,7 +143,8 @@ } else { - Orthanc::ImageAccessor accessor = target.GetRegion(left_, top_, width_, height_); + Orthanc::ImageAccessor accessor; + target.GetRegion(accessor, left_, top_, width_, height_); return widget_->Render(accessor); } } @@ -173,7 +175,8 @@ { if (Contains(x, y)) { - Orthanc::ImageAccessor accessor = target.GetRegion(left_, top_, width_, height_); + Orthanc::ImageAccessor accessor; + target.GetRegion(accessor, left_, top_, width_, height_); widget_->RenderMouseOver(accessor, x - left_, y - top_); }