Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introduce "frame-of-reference" #123

Merged
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f349ede
Add coordinate systems documentation and diagram
ptahmose Dec 4, 2024
a872ba2
Update coordinate systems documentation in libCZI
ptahmose Dec 4, 2024
6dafc60
Improve documentation clarity for coordinate systems
ptahmose Dec 4, 2024
9ef751b
Update project to version 0.62.7
ptahmose Dec 4, 2024
0615672
remove "high-res-bitmaps"
ptahmose Dec 4, 2024
56c1511
wip
ptahmose Dec 4, 2024
6ac0145
fix table
ptahmose Dec 4, 2024
c15a59d
cosmetic
ptahmose Dec 4, 2024
bb9f897
Refactor coordinate handling and improve documentation
ptahmose Dec 5, 2024
4baeca7
merge with main
ptahmose Dec 5, 2024
17b4b15
Refactor coordinate transformation methods
ptahmose Dec 5, 2024
aaf0bbe
Update TransformPoint to return IntPointAndFrameOfReference
ptahmose Dec 6, 2024
46f0b73
Add frame of reference handling and related tests
ptahmose Dec 9, 2024
49f7a9f
linter
ptahmose Dec 9, 2024
52e391a
cosmetic
ptahmose Dec 9, 2024
267c0cc
Refactor TransformPoint and add new tests
ptahmose Dec 11, 2024
b7bedc7
Add TransformPoint method and default frame of reference
ptahmose Dec 11, 2024
98117a0
Update bounding-box and transformation expectations
ptahmose Dec 11, 2024
9135c59
Refactor and cleanup in SingleChannelTileAccessor
ptahmose Dec 11, 2024
e44c627
Refactor to use IntPointAndFrameOfReference type
ptahmose Dec 11, 2024
1c5470d
linter
ptahmose Dec 11, 2024
265e58f
Improve comment formatting in Z-order description
ptahmose Dec 11, 2024
8322d3d
Refactor Get methods and update documentation
ptahmose Dec 11, 2024
83f4244
Refactor coordinate handling to use explicit frames
ptahmose Dec 11, 2024
0d7b1ed
Refactor ROI coordinate calculation and formatting
ptahmose Dec 11, 2024
ac8ea26
Update project to version 0.63.0
ptahmose Dec 11, 2024
a734238
add documentation
ptahmose Dec 11, 2024
d83f9ca
fix typos
ptahmose Dec 11, 2024
6e7fcc0
Update Src/CZICmd/execute.cpp
ptahmose Dec 12, 2024
f4023d4
Update Src/libCZI/libCZI_ReadWrite.h
ptahmose Dec 12, 2024
826e36c
Simplify return statements with brace-enclosed initializer
ptahmose Dec 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.15)
cmake_policy(SET CMP0091 NEW) # enable new "MSVC runtime library selection" (https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html)

project(libCZI
VERSION 0.62.7
VERSION 0.63.0
HOMEPAGE_URL "https://github.com/ZEISS/libczi"
DESCRIPTION "libCZI is an Open Source Cross-Platform C++ library to read and write CZI")

Expand Down
14 changes: 7 additions & 7 deletions Src/CZICmd/execute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,12 +556,12 @@ class CExecuteSingleChannelTileAccessor : CExecuteBase
sctaOptions.sceneFilter = options.GetSceneIndexSet();
sctaOptions.useVisibilityCheckOptimization = options.GetUseVisibilityCheckOptimization();

IntRect roi{ options.GetRectX() ,options.GetRectY(),options.GetRectW(),options.GetRectH() };
IntRect roi{ options.GetRectX() ,options.GetRectY(), options.GetRectW(), options.GetRectH() };
ptahmose marked this conversation as resolved.
Show resolved Hide resolved
if (options.GetIsRelativeRectCoordinate())
{
auto statistics = spReader->GetStatistics();
roi.x += statistics.boundingBox.x;
roi.y += statistics.boundingBox.y;
roi.x += statistics.boundingBoxLayer0Only.x;
roi.y += statistics.boundingBoxLayer0Only.y;
}

auto re = accessor->Get(roi, &coordinate, &sctaOptions);
Expand Down Expand Up @@ -676,8 +676,8 @@ class CExecuteChannelComposite : CExecuteBase
IntRect roi{ options.GetRectX() ,options.GetRectY() ,options.GetRectW(),options.GetRectH() };
if (options.GetIsRelativeRectCoordinate())
{
roi.x += subBlockStatistics.boundingBox.x;
roi.y += subBlockStatistics.boundingBox.y;
roi.x += subBlockStatistics.boundingBoxLayer0Only.x;
roi.y += subBlockStatistics.boundingBoxLayer0Only.y;
}

auto accessor = reader->CreateSingleChannelTileAccessor();
Expand Down Expand Up @@ -861,8 +861,8 @@ class CExecuteScalingChannelComposite : CExecuteBase
IntRect roi{ options.GetRectX() ,options.GetRectY() ,options.GetRectW(),options.GetRectH() };
if (options.GetIsRelativeRectCoordinate())
{
roi.x += subBlockStatistics.boundingBox.x;
roi.y += subBlockStatistics.boundingBox.y;
roi.x += subBlockStatistics.boundingBoxLayer0Only.x;
roi.y += subBlockStatistics.boundingBoxLayer0Only.y;
}

auto accessor = reader->CreateSingleChannelScalingTileAccessor();
Expand Down
4 changes: 2 additions & 2 deletions Src/CZICmd/executeBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ IntRect CExecuteBase::GetRoiFromOptions(const CCmdLineOptions& options, const Su
IntRect roi{ options.GetRectX(), options.GetRectY(), options.GetRectW(), options.GetRectH() };
if (options.GetIsRelativeRectCoordinate())
{
roi.x += subBlockStatistics.boundingBox.x;
roi.y += subBlockStatistics.boundingBox.y;
roi.x += subBlockStatistics.boundingBoxLayer0Only.x;
roi.y += subBlockStatistics.boundingBoxLayer0Only.y;
}

return roi;
Expand Down
69 changes: 66 additions & 3 deletions Src/libCZI/CZIReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
return parse_options;
}

CCZIReader::CCZIReader() : isOperational(false)
CCZIReader::CCZIReader() : isOperational(false), default_frame_of_reference(CZIFrameOfReference::Invalid)
{
}

Expand Down Expand Up @@ -60,6 +60,17 @@
}

this->stream = stream;
switch (options->default_frame_of_reference)
{
case CZIFrameOfReference::Invalid:
case CZIFrameOfReference::Default:
this->default_frame_of_reference = CZIFrameOfReference::RawSubBlockCoordinateSystem;
break;
default:
this->default_frame_of_reference = options->default_frame_of_reference;
break;
}

this->SetOperationalState(true);
}

Expand Down Expand Up @@ -96,6 +107,58 @@
return this->subBlkDir.GetPyramidStatistics();
}

/*virtual*/libCZI::IntPointAndFrameOfReference CCZIReader::TransformPoint(const libCZI::IntPointAndFrameOfReference& source_point, libCZI::CZIFrameOfReference destination_frame_of_reference)
ptahmose marked this conversation as resolved.
Show resolved Hide resolved
{
CZIFrameOfReference source_frame_of_reference_consolidated;
switch (source_point.frame_of_reference)
{
case CZIFrameOfReference::RawSubBlockCoordinateSystem:
case CZIFrameOfReference::PixelCoordinateSystem:
source_frame_of_reference_consolidated = source_point.frame_of_reference;
break;
case CZIFrameOfReference::Default:
source_frame_of_reference_consolidated = this->default_frame_of_reference;
break;
default:
throw invalid_argument("Unsupported frame-of-reference.");

Check warning on line 123 in Src/libCZI/CZIReader.cpp

View check run for this annotation

Codecov / codecov/patch

Src/libCZI/CZIReader.cpp#L123

Added line #L123 was not covered by tests
}

CZIFrameOfReference destination_frame_of_reference_consolidated;
switch (destination_frame_of_reference)
{
case CZIFrameOfReference::RawSubBlockCoordinateSystem:
case CZIFrameOfReference::PixelCoordinateSystem:
destination_frame_of_reference_consolidated = destination_frame_of_reference;
break;
case CZIFrameOfReference::Default:
destination_frame_of_reference_consolidated = this->default_frame_of_reference;
break;
default:
throw invalid_argument("Unsupported frame-of-reference.");
}

if (destination_frame_of_reference_consolidated == source_frame_of_reference_consolidated)
{
return { source_frame_of_reference_consolidated, source_point.point };
}

if (source_frame_of_reference_consolidated == CZIFrameOfReference::PixelCoordinateSystem &&
destination_frame_of_reference_consolidated == CZIFrameOfReference::RawSubBlockCoordinateSystem)
{
const auto& statistics = this->subBlkDir.GetStatistics();
return libCZI::IntPointAndFrameOfReference{ CZIFrameOfReference::RawSubBlockCoordinateSystem, {source_point.point.x + statistics.boundingBoxLayer0Only.x, source_point.point.y + statistics.boundingBoxLayer0Only.y} };
ptahmose marked this conversation as resolved.
Show resolved Hide resolved
ptahmose marked this conversation as resolved.
Show resolved Hide resolved
}

if (source_frame_of_reference_consolidated == CZIFrameOfReference::RawSubBlockCoordinateSystem &&
destination_frame_of_reference_consolidated == CZIFrameOfReference::PixelCoordinateSystem)
{
const auto& statistics = this->subBlkDir.GetStatistics();
return libCZI::IntPointAndFrameOfReference{ CZIFrameOfReference::PixelCoordinateSystem, {source_point.point.x - statistics.boundingBoxLayer0Only.x, source_point.point.y - statistics.boundingBoxLayer0Only.y} };
ptahmose marked this conversation as resolved.
Show resolved Hide resolved
}

throw logic_error("Unsupported frame-of-reference transformation.");

Check warning on line 159 in Src/libCZI/CZIReader.cpp

View check run for this annotation

Codecov / codecov/patch

Src/libCZI/CZIReader.cpp#L159

Added line #L159 was not covered by tests
}

/*virtual*/void CCZIReader::EnumerateSubBlocks(const std::function<bool(int index, const SubBlockInfo& info)>& funcEnum)
{
this->ThrowIfNotOperational();
Expand Down Expand Up @@ -205,8 +268,8 @@
this->ThrowIfNotOperational();
CziReaderCommon::EnumerateSubset(
std::bind(&CCziAttachmentsDirectory::EnumAttachments, &this->attachmentDir, std::placeholders::_1),
contentFileType,
name,
contentFileType,
name,
funcEnum);
}

Expand Down
2 changes: 2 additions & 0 deletions Src/libCZI/CZIReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class CCZIReader : public libCZI::ICZIReader, public std::enable_shared_from_thi
CCziSubBlockDirectory subBlkDir;
CCziAttachmentsDirectory attachmentDir;
bool isOperational; ///< If true, then stream, hdrSegmentData and subBlkDir can be considered valid and operational
libCZI::CZIFrameOfReference default_frame_of_reference;
public:
CCZIReader();
~CCZIReader() override = default;
Expand All @@ -33,6 +34,7 @@ class CCZIReader : public libCZI::ICZIReader, public std::enable_shared_from_thi
bool TryGetSubBlockInfo(int index, libCZI::SubBlockInfo* info) const override;
libCZI::SubBlockStatistics GetStatistics() override;
libCZI::PyramidStatistics GetPyramidStatistics() override;
libCZI::IntPointAndFrameOfReference TransformPoint(const libCZI::IntPointAndFrameOfReference& source_point, libCZI::CZIFrameOfReference destination_frame_of_reference) override;

// interface ISubBlockRepositoryEx
void EnumerateSubBlocksEx(const std::function<bool(int index, const libCZI::DirectorySubBlockInfo& info)>& funcEnum) override;
Expand Down
80 changes: 73 additions & 7 deletions Src/libCZI/CziReaderWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
int key;
ICziReaderWriter* t;
ReplaceHelper(int key, ICziReaderWriter* t)
:key(key), t(t) {}
:key(key), t(t)
{}

void operator()(const AddSubBlockInfo& addSbBlkInfo) const
{
Expand All @@ -60,17 +61,17 @@
void ICziReaderWriter::ReplaceSubBlock(int key, const libCZI::AddSubBlockInfoMemPtr& addSbBlkInfoMemPtr)
{
struct ReplaceHelper f(key, this);
AddSubBlockHelper::SyncAddSubBlock<ReplaceHelper >(f, addSbBlkInfoMemPtr);
AddSubBlockHelper::SyncAddSubBlock<ReplaceHelper>(f, addSbBlkInfoMemPtr);
}
void ICziReaderWriter::ReplaceSubBlock(int key, const libCZI::AddSubBlockInfoLinewiseBitmap& addSbInfoLinewise)
{
struct ReplaceHelper f(key, this);
AddSubBlockHelper::SyncAddSubBlock<ReplaceHelper >(f, addSbInfoLinewise);
AddSubBlockHelper::SyncAddSubBlock<ReplaceHelper>(f, addSbInfoLinewise);

Check warning on line 69 in Src/libCZI/CziReaderWriter.cpp

View check run for this annotation

Codecov / codecov/patch

Src/libCZI/CziReaderWriter.cpp#L69

Added line #L69 was not covered by tests
}
void ICziReaderWriter::ReplaceSubBlock(int key, const libCZI::AddSubBlockInfoStridedBitmap& addSbBlkInfoStrideBitmap)
{
struct ReplaceHelper f(key, this);
AddSubBlockHelper::SyncAddSubBlock<ReplaceHelper >(f, addSbBlkInfoStrideBitmap);
AddSubBlockHelper::SyncAddSubBlock<ReplaceHelper>(f, addSbBlkInfoStrideBitmap);

Check warning on line 74 in Src/libCZI/CziReaderWriter.cpp

View check run for this annotation

Codecov / codecov/patch

Src/libCZI/CziReaderWriter.cpp#L74

Added line #L74 was not covered by tests
}

//--------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -335,7 +336,7 @@

void CCziReaderWriter::UpdateFileHeader()
{
FileHeaderSegment fhs = { 0 };
FileHeaderSegment fhs = {};

fhs.header.AllocatedSize = fhs.header.UsedSize = sizeof(fhs.data);
memcpy(&fhs.header.Id, &CCZIParse::FILEHDRMAGIC, 16);
Expand Down Expand Up @@ -430,7 +431,7 @@
else
{
// if there is no valid CZI-file-header, we now write one
FileHeaderSegment fhs = { 0 };
FileHeaderSegment fhs = {};
fhs.header.AllocatedSize = fhs.header.UsedSize = sizeof(fhs.data);
memcpy(&fhs.header.Id, &CCZIParse::FILEHDRMAGIC, 16);

Expand Down Expand Up @@ -489,7 +490,7 @@
this->attachmentDirectory.EnumEntries(
[&](size_t index, const CCziAttachmentsDirectoryBase::AttachmentEntry& attEntry)->bool
{
if (uint64_t(attEntry.FilePosition) > lastSegmentPos)
if (static_cast<uint64_t>(attEntry.FilePosition) > lastSegmentPos)
{
lastSegmentPos = attEntry.FilePosition;
}
Expand Down Expand Up @@ -712,6 +713,58 @@
return this->sbBlkDirectory.GetPyramidStatistics();
}

/*virtual*/libCZI::IntPointAndFrameOfReference CCziReaderWriter::TransformPoint(const libCZI::IntPointAndFrameOfReference& source_point, libCZI::CZIFrameOfReference destination_frame_of_reference)
{
CZIFrameOfReference source_frame_of_reference_consolidated;
switch (source_point.frame_of_reference)
{
case CZIFrameOfReference::RawSubBlockCoordinateSystem:
case CZIFrameOfReference::PixelCoordinateSystem:
source_frame_of_reference_consolidated = source_point.frame_of_reference;
break;
case CZIFrameOfReference::Default:
source_frame_of_reference_consolidated = this->GetDefaultFrameOfReference();
break;

Check warning on line 727 in Src/libCZI/CziReaderWriter.cpp

View check run for this annotation

Codecov / codecov/patch

Src/libCZI/CziReaderWriter.cpp#L726-L727

Added lines #L726 - L727 were not covered by tests
default:
throw invalid_argument("Unsupported frame-of-reference.");

Check warning on line 729 in Src/libCZI/CziReaderWriter.cpp

View check run for this annotation

Codecov / codecov/patch

Src/libCZI/CziReaderWriter.cpp#L729

Added line #L729 was not covered by tests
}

CZIFrameOfReference destination_frame_of_reference_consolidated;
switch (destination_frame_of_reference)
{
case CZIFrameOfReference::RawSubBlockCoordinateSystem:
case CZIFrameOfReference::PixelCoordinateSystem:
destination_frame_of_reference_consolidated = destination_frame_of_reference;
break;
case CZIFrameOfReference::Default:
destination_frame_of_reference_consolidated = this->GetDefaultFrameOfReference();
break;

Check warning on line 741 in Src/libCZI/CziReaderWriter.cpp

View check run for this annotation

Codecov / codecov/patch

Src/libCZI/CziReaderWriter.cpp#L740-L741

Added lines #L740 - L741 were not covered by tests
default:
throw invalid_argument("Unsupported frame-of-reference.");

Check warning on line 743 in Src/libCZI/CziReaderWriter.cpp

View check run for this annotation

Codecov / codecov/patch

Src/libCZI/CziReaderWriter.cpp#L743

Added line #L743 was not covered by tests
}

if (destination_frame_of_reference_consolidated == source_frame_of_reference_consolidated)
{
return { source_frame_of_reference_consolidated, source_point.point };

Check warning on line 748 in Src/libCZI/CziReaderWriter.cpp

View check run for this annotation

Codecov / codecov/patch

Src/libCZI/CziReaderWriter.cpp#L748

Added line #L748 was not covered by tests
}

if (source_frame_of_reference_consolidated == CZIFrameOfReference::PixelCoordinateSystem &&
destination_frame_of_reference_consolidated == CZIFrameOfReference::RawSubBlockCoordinateSystem)
{
const auto& statistics = this->GetStatistics();
return libCZI::IntPointAndFrameOfReference{ CZIFrameOfReference::RawSubBlockCoordinateSystem, {source_point.point.x + statistics.boundingBoxLayer0Only.x, source_point.point.y + statistics.boundingBoxLayer0Only.y} };
}

if (source_frame_of_reference_consolidated == CZIFrameOfReference::RawSubBlockCoordinateSystem &&

Check warning on line 758 in Src/libCZI/CziReaderWriter.cpp

View check run for this annotation

Codecov / codecov/patch

Src/libCZI/CziReaderWriter.cpp#L758

Added line #L758 was not covered by tests
destination_frame_of_reference_consolidated == CZIFrameOfReference::PixelCoordinateSystem)
{
const auto& statistics = this->GetStatistics();
return libCZI::IntPointAndFrameOfReference{ CZIFrameOfReference::PixelCoordinateSystem, {source_point.point.x - statistics.boundingBoxLayer0Only.x, source_point.point.y - statistics.boundingBoxLayer0Only.y} };

Check warning on line 762 in Src/libCZI/CziReaderWriter.cpp

View check run for this annotation

Codecov / codecov/patch

Src/libCZI/CziReaderWriter.cpp#L761-L762

Added lines #L761 - L762 were not covered by tests
}

throw logic_error("Unsupported frame-of-reference transformation.");

Check warning on line 765 in Src/libCZI/CziReaderWriter.cpp

View check run for this annotation

Codecov / codecov/patch

Src/libCZI/CziReaderWriter.cpp#L765

Added line #L765 was not covered by tests
}

/*virtual*/void CCziReaderWriter::EnumerateAttachments(const std::function<bool(int index, const libCZI::AttachmentInfo& info)>& funcEnum)
{
this->ThrowIfNotOperational();
Expand Down Expand Up @@ -874,3 +927,16 @@
throw logic_error("CCziReaderWriter is already operational.");
}
}

libCZI::CZIFrameOfReference CCziReaderWriter::GetDefaultFrameOfReference() const
{
const auto default_frame_of_reference_from_info = this->info->GetDefaultFrameOfReference();
switch (default_frame_of_reference_from_info)

Check warning on line 934 in Src/libCZI/CziReaderWriter.cpp

View check run for this annotation

Codecov / codecov/patch

Src/libCZI/CziReaderWriter.cpp#L932-L934

Added lines #L932 - L934 were not covered by tests
{
case CZIFrameOfReference::RawSubBlockCoordinateSystem:
case CZIFrameOfReference::PixelCoordinateSystem:
return default_frame_of_reference_from_info;

Check warning on line 938 in Src/libCZI/CziReaderWriter.cpp

View check run for this annotation

Codecov / codecov/patch

Src/libCZI/CziReaderWriter.cpp#L938

Added line #L938 was not covered by tests
default:
return CZIFrameOfReference::RawSubBlockCoordinateSystem;

Check warning on line 940 in Src/libCZI/CziReaderWriter.cpp

View check run for this annotation

Codecov / codecov/patch

Src/libCZI/CziReaderWriter.cpp#L940

Added line #L940 was not covered by tests
}
}

Check warning on line 942 in Src/libCZI/CziReaderWriter.cpp

View check run for this annotation

Codecov / codecov/patch

Src/libCZI/CziReaderWriter.cpp#L942

Added line #L942 was not covered by tests
2 changes: 2 additions & 0 deletions Src/libCZI/CziReaderWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class CCziReaderWriter : public libCZI::ICziReaderWriter
bool TryGetSubBlockInfo(int index, libCZI::SubBlockInfo* info) const override;
libCZI::SubBlockStatistics GetStatistics() override;
libCZI::PyramidStatistics GetPyramidStatistics() override;
libCZI::IntPointAndFrameOfReference TransformPoint(const libCZI::IntPointAndFrameOfReference& source_point, libCZI::CZIFrameOfReference destination_frame_of_reference) override;

// interface IAttachmentRepository
void EnumerateAttachments(const std::function<bool(int index, const libCZI::AttachmentInfo& info)>& funcEnum) override;
Expand Down Expand Up @@ -80,6 +81,7 @@ class CCziReaderWriter : public libCZI::ICziReaderWriter
void UpdateFileHeader();
void ThrowIfNotOperational() const;
void ThrowIfAlreadyInitialized() const;
libCZI::CZIFrameOfReference GetDefaultFrameOfReference() const;
private:
class CNextSegment
{
Expand Down
3 changes: 2 additions & 1 deletion Src/libCZI/Doc/version-history.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ version history {#version_history}
0.62.4 | [117](https://github.com/ZEISS/libczi/pull/117) | fix build with private RapidJSON library
0.62.5 | [119](https://github.com/ZEISS/libczi/pull/119) | fix a discrepancy between code and documentation
0.62.6 | [120](https://github.com/ZEISS/libczi/pull/120) | fix workload identity in the azure blob inputstream
0.62.7 | [122](https://github.com/ZEISS/libczi/pull/122) | documentation update
0.62.7 | [122](https://github.com/ZEISS/libczi/pull/122) | documentation update
0.63.0 | [123](https://github.com/ZEISS/libczi/pull/123) | introduce "frames-of-reference"
16 changes: 9 additions & 7 deletions Src/libCZI/SingleChannelPyramidLevelTileAccessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{
}

/*virtual*/std::shared_ptr<libCZI::IBitmapData> CSingleChannelPyramidLevelTileAccessor::Get(const libCZI::IntRect& roi, const libCZI::IDimCoordinate* planeCoordinate, const PyramidLayerInfo& pyramidInfo, const ISingleChannelPyramidLayerTileAccessor::Options* pOptions)
/*virtual*/std::shared_ptr<libCZI::IBitmapData> CSingleChannelPyramidLevelTileAccessor::Get(const libCZI::IntRectAndFrameOfReference& roi, const libCZI::IDimCoordinate* planeCoordinate, const PyramidLayerInfo& pyramidInfo, const ISingleChannelPyramidLayerTileAccessor::Options* pOptions)
{
if (pOptions == nullptr)
{
Expand All @@ -34,7 +34,7 @@
return this->Get(pixelType, roi, planeCoordinate, pyramidInfo, pOptions);
}

/*virtual*/std::shared_ptr<libCZI::IBitmapData> CSingleChannelPyramidLevelTileAccessor::Get(libCZI::PixelType pixeltype, const libCZI::IntRect& roi, const libCZI::IDimCoordinate* planeCoordinate, const PyramidLayerInfo& pyramidInfo, const libCZI::ISingleChannelPyramidLayerTileAccessor::Options* pOptions)
/*virtual*/std::shared_ptr<libCZI::IBitmapData> CSingleChannelPyramidLevelTileAccessor::Get(libCZI::PixelType pixeltype, const libCZI::IntRectAndFrameOfReference& roi, const libCZI::IDimCoordinate* planeCoordinate, const PyramidLayerInfo& pyramidInfo, const libCZI::ISingleChannelPyramidLayerTileAccessor::Options* pOptions)
{
if (pOptions == nullptr)
{
Expand All @@ -43,31 +43,33 @@
return this->Get(pixeltype, roi, planeCoordinate, pyramidInfo, &opt);
}

const IntRect roi_raw_sub_block_cs = this->sbBlkRepository->TransformRectangle(roi, CZIFrameOfReference::RawSubBlockCoordinateSystem).rectangle;
const int sizeOfPixel = CalcSizeOfPixelOnLayer0(pyramidInfo);
const IntSize sizeOfBitmap{ static_cast<std::uint32_t>(roi.w / sizeOfPixel),static_cast<std::uint32_t>(roi.h / sizeOfPixel) };
const IntSize sizeOfBitmap{ static_cast<std::uint32_t>(roi_raw_sub_block_cs.w / sizeOfPixel),static_cast<std::uint32_t>(roi_raw_sub_block_cs.h / sizeOfPixel) };
if (sizeOfBitmap.w == 0 || sizeOfBitmap.h == 0)
{
// TODO
throw runtime_error("error");
}

auto bmDest = GetSite()->CreateBitmap(pixeltype, sizeOfBitmap.w, sizeOfBitmap.h);
this->InternalGet(bmDest.get(), roi.x, roi.y, sizeOfPixel, planeCoordinate, pyramidInfo, *pOptions);
this->InternalGet(bmDest.get(), roi_raw_sub_block_cs.x, roi_raw_sub_block_cs.y, sizeOfPixel, planeCoordinate, pyramidInfo, *pOptions);
return bmDest;
}

/*virtual*/void CSingleChannelPyramidLevelTileAccessor::Get(libCZI::IBitmapData* pDest, int xPos, int yPos, const libCZI::IDimCoordinate* planeCoordinate, const PyramidLayerInfo& pyramidInfo, const Options* pOptions)
/*virtual*/void CSingleChannelPyramidLevelTileAccessor::Get(libCZI::IBitmapData* pDest, const libCZI::IntPointAndFrameOfReference& position, const libCZI::IDimCoordinate* planeCoordinate, const PyramidLayerInfo& pyramidInfo, const Options* pOptions)
{
if (pOptions == nullptr)
{
Options opt;
opt.Clear();
this->Get(pDest, xPos, yPos, planeCoordinate, pyramidInfo, &opt);
this->Get(pDest, position, planeCoordinate, pyramidInfo, &opt);

Check warning on line 66 in Src/libCZI/SingleChannelPyramidLevelTileAccessor.cpp

View check run for this annotation

Codecov / codecov/patch

Src/libCZI/SingleChannelPyramidLevelTileAccessor.cpp#L66

Added line #L66 was not covered by tests
return;
}

const IntPoint point_raw_sub_block_cs = this->sbBlkRepository->TransformPoint(position, CZIFrameOfReference::RawSubBlockCoordinateSystem).point;

Check warning on line 70 in Src/libCZI/SingleChannelPyramidLevelTileAccessor.cpp

View check run for this annotation

Codecov / codecov/patch

Src/libCZI/SingleChannelPyramidLevelTileAccessor.cpp#L70

Added line #L70 was not covered by tests
const int sizeOfPixel = CalcSizeOfPixelOnLayer0(pyramidInfo);
this->InternalGet(pDest, xPos, yPos, sizeOfPixel, planeCoordinate, pyramidInfo, *pOptions);
this->InternalGet(pDest, point_raw_sub_block_cs.x, point_raw_sub_block_cs.y, sizeOfPixel, planeCoordinate, pyramidInfo, *pOptions);

Check warning on line 72 in Src/libCZI/SingleChannelPyramidLevelTileAccessor.cpp

View check run for this annotation

Codecov / codecov/patch

Src/libCZI/SingleChannelPyramidLevelTileAccessor.cpp#L72

Added line #L72 was not covered by tests
}

void CSingleChannelPyramidLevelTileAccessor::InternalGet(libCZI::IBitmapData* pDest, int xPos, int yPos, int sizeOfPixelOnLayer0, const libCZI::IDimCoordinate* planeCoordinate, const PyramidLayerInfo& pyramidInfo, const Options& options)
Expand Down
Loading
Loading