/**
* Orthanc - A Lightweight, RESTful DICOM Store
* Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
* Department, University Hospital of Liege, Belgium
* Copyright (C) 2017-2023 Osimis S.A., Belgium
* Copyright (C) 2024-2025 Orthanc Team SRL, Belgium
* Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program. If not, see
* .
**/
#pragma once
#include "../Compatibility.h"
#include "../Enumerations.h"
#include
#include
#include
namespace Orthanc
{
class ORTHANC_PUBLIC ImageAccessor : public boost::noncopyable
{
private:
template
friend struct ImageTraits;
bool readOnly_;
PixelFormat format_;
unsigned int width_;
unsigned int height_;
unsigned int pitch_;
uint8_t *buffer_;
template
const T& GetPixelUnchecked(unsigned int x,
unsigned int y) const
{
const uint8_t* row = reinterpret_cast(buffer_) + y * pitch_;
return reinterpret_cast(row) [x];
}
template
T& GetPixelUnchecked(unsigned int x,
unsigned int y)
{
uint8_t* row = reinterpret_cast(buffer_) + y * pitch_;
return reinterpret_cast(row) [x];
}
#if ORTHANC_BUILDING_FRAMEWORK_LIBRARY == 1
// Alias for binary compatibility with Orthanc Framework 1.7.2 => don't use it anymore
void* GetBuffer() const;
void* GetRow(unsigned int y) const;
#endif
public:
ImageAccessor();
virtual ~ImageAccessor();
bool IsReadOnly() const;
PixelFormat GetFormat() const;
unsigned int GetBytesPerPixel() const;
unsigned int GetWidth() const;
unsigned int GetHeight() const;
unsigned int GetPitch() const;
size_t GetSize() const;
const void* GetConstBuffer() const;
void* GetBuffer();
const void* GetConstRow(unsigned int y) const;
void* GetRow(unsigned int y);
void AssignEmpty(PixelFormat format);
void AssignReadOnly(PixelFormat format,
unsigned int width,
unsigned int height,
unsigned int pitch,
const void *buffer);
void GetReadOnlyAccessor(ImageAccessor& target) const;
void AssignWritable(PixelFormat format,
unsigned int width,
unsigned int height,
unsigned int pitch,
void *buffer);
void GetWriteableAccessor(ImageAccessor& target) const;
void ToMatlabString(std::string& target) const;
void GetRegion(ImageAccessor& accessor,
unsigned int x,
unsigned int y,
unsigned int width,
unsigned int height) const;
void SetFormat(PixelFormat format);
};
}