SlideIO 2.0.0
Open-source library for reading of medical images
Loading...
Searching...
No Matches
converterparameters.hpp
1// This file is part of slideio project.
2// It is subject to the license terms in the LICENSE file found in the top-level directory
3// of this distribution and at http://slideio.com/license.html.
4#pragma once
5#include "slideio/imagetools/encodeparameters.hpp"
6
7namespace slideio
8{
9 enum ImageFormat {
10 Unknown,
11 SVS
12 };
13
14 enum ConverterEncoding {
15 UNKNOWN_ENCODING,
16 JPEG,
17 JPEG2000
18
19 };
20
21 struct Rectangle
22 {
23 int32_t x = -1;
24 int32_t y = -1;
25 int32_t width = 0;
26 int32_t height = 0;
27 bool isValid() const { return x >= 0 && y >= 0 && width > 0 && height > 0; }
28 };
29
30 class ConverterParameters
31 {
32 protected:
33 ConverterParameters() : m_format(ImageFormat::Unknown), m_zSlice(0), m_tFrame(0) {
34 }
35 public:
36 ImageFormat getFormat() const {
37 return m_format;
38 }
39 Rectangle& getRect() {
40 return m_rect;
41 }
42 void setRect(const Rectangle& rect) {
43 m_rect = rect;
44 }
45 int32_t getZSlice() const {
46 return m_zSlice;
47 }
48 void setZSlice(int32_t zSlice) {
49 m_zSlice = zSlice;
50 }
51 int32_t getTFrame() const {
52 return m_tFrame;
53 }
54 void setTFrame(int32_t tFrame) {
55 m_tFrame = tFrame;
56 }
57 protected:
58 ImageFormat m_format;
59 Rectangle m_rect;
60 int32_t m_zSlice;
61 int32_t m_tFrame;
62 };
63
64 class SVSConverterParameters : public ConverterParameters
65 {
66 protected:
67 SVSConverterParameters() : m_tileWidth(256),
68 m_tileHeight(256),
69 m_numZoomLevels(-1),
70 m_tileEncoding(Compression::Unknown) {
71 m_format = ImageFormat::SVS;
72 }
73 public:
74 Compression getEncoding() const {
75 return m_tileEncoding;
76 }
77 int getTileWidth() const {
78 return m_tileWidth;
79 }
80 void setTileWidth(int tileWidth) {
81 m_tileWidth = tileWidth;
82 }
83 int getTileHeight() const {
84 return m_tileHeight;
85 }
86 void setTileHeight(int tileHeight) {
87 m_tileHeight = tileHeight;
88 }
89 int getNumZoomLevels() const {
90 return m_numZoomLevels;
91 }
92 void setNumZoomLevels(int numZoomLevels) {
93 m_numZoomLevels = numZoomLevels;
94 }
95 virtual EncodeParameters& getEncodeParameters() = 0;
96 virtual const EncodeParameters& getEncodeParameters() const = 0;
97 protected:
98 Compression m_tileEncoding;
99 int m_tileWidth;
100 int m_tileHeight;
101 int m_numZoomLevels;
102 };
103
104 class SVSJpegConverterParameters : public SVSConverterParameters,
105 public JpegEncodeParameters
106 {
107 public:
108 SVSJpegConverterParameters(){
109 m_tileEncoding = Compression::Jpeg;
110 }
111 EncodeParameters& getEncodeParameters() override {
112 return static_cast<JpegEncodeParameters&>(*this);
113 }
114 const EncodeParameters& getEncodeParameters() const override {
115 return static_cast<const JpegEncodeParameters&>(*this);
116 }
117 };
118
119 class SVSJp2KConverterParameters : public SVSConverterParameters,
120 public JP2KEncodeParameters
121 {
122 public:
123 SVSJp2KConverterParameters() {
124 m_tileEncoding = Compression::Jpeg2000;
125 }
126 EncodeParameters& getEncodeParameters() override {
127 return static_cast<JP2KEncodeParameters&>(*this);
128 }
129 const EncodeParameters& getEncodeParameters() const override {
130 return static_cast<const JP2KEncodeParameters&>(*this);
131 }
132 };
133}
134
Definition: exceptions.hpp:12
Compression
raster data compression enum
Definition: slideio_enums.hpp:12
@ Jpeg
JPEG compression.
@ Jpeg2000
JPEG 2000 compression.