5#include "slideio/core/slideio_core_def.hpp"
6#include "slideio/base/slideio_structs.hpp"
10#pragma warning( push )
11#pragma warning(disable: 4251)
30 os <<
"Level: " << levelInfo.
getLevel() << std::endl;
31 os <<
"Size: " << levelInfo.
getSize().width <<
"x" << levelInfo.
getSize().height << std::endl;
32 os <<
"Scale: " << levelInfo.
getScale() << std::endl;
34 os <<
"Tile Size: " << levelInfo.
getTileSize().width <<
"x" << levelInfo.
getTileSize().height << std::endl;
40 LevelInfo(
int level,
const Size& size,
double scale,
double magnification,
const Size& tileSize)
41 : m_level(level), m_size(size), m_scale(scale), m_magnification(magnification), m_tileSize(tileSize) {}
44 m_level = other.m_level;
45 m_size = other.m_size;
46 m_scale = other.m_scale;
47 m_magnification = other.m_magnification;
48 m_tileSize = other.m_tileSize;
53 m_level = other.m_level;
54 m_size = other.m_size;
55 m_scale = other.m_scale;
56 m_magnification = other.m_magnification;
57 m_tileSize = other.m_tileSize;
62 bool operator==(
const LevelInfo& other)
const {
63 return m_level == other.m_level &&
64 m_size.width == other.m_size.width &&
65 m_size.height == other.m_size.height &&
66 std::fabs(m_scale - other.m_scale) < 1.e-2 &&
67 std::fabs(m_magnification - other.m_magnification) < 1.e-2 &&
68 m_tileSize.width == other.m_tileSize.width &&
69 m_tileSize.height == other.m_tileSize.height;
74 if (getTileSize().width > 0 && getTileSize().height > 0) {
75 const int tilesX = (getSize().width - 1) / getTileSize().width + 1;
76 const int tilesY = (getSize().height - 1) / getTileSize().height + 1;
77 m_tileCount = tilesX * tilesY;
86 void setLevel(
int level) { m_level = level; }
90 void setSize(
const Size& size) { m_size = size; }
97 void setScale(
double scale) { m_scale = scale; }
101 void setMagnification(
double magnification) { m_magnification = magnification; }
105 void setTileSize(
const Size& tileSize) { m_tileSize = tileSize; }
118 std::string toString()
const;
133 const int tileCount = getTileCount();
135 const int tilesX = (m_size.width - 1) / m_tileSize.width + 1;
136 const int tilesY = (m_size.height - 1) / m_tileSize.height + 1;
137 const int tileY = tileIndex / tilesX;
138 const int tileX = tileIndex % tilesX;
139 tileRect.x = tileX * m_tileSize.width;
140 tileRect.y = tileY * m_tileSize.height;
141 tileRect.width = m_tileSize.width;
142 tileRect.height = m_tileSize.height;
147 tileRect.width = m_size.width;
148 tileRect.height = m_size.height;
156 double m_scale = 0.0;
157 double m_magnification = 0.0;
159 mutable int m_tileCount = 0;
164#pragma warning( pop )
Description of a single level of the internal image pyramid of a scene.
Definition: levelinfo.hpp:26
double getMagnification() const
returns the objective magnification of the level. 0 if the format does not report it.
Definition: levelinfo.hpp:100
void updateTileCount() const
recomputes the cached tile count from the current level and tile size.
Definition: levelinfo.hpp:73
Size getSize() const
returns the size of the level in the pixels of the level.
Definition: levelinfo.hpp:89
Rect getTileRect(int tileIndex) const
returns the rectangle of a tile in the coordinate system of the level.
Definition: levelinfo.hpp:131
double getScale() const
returns the scale of the level relative to level 0.
Definition: levelinfo.hpp:96
int getLevel() const
returns the index of the level. Level 0 is the level of the highest resolution.
Definition: levelinfo.hpp:85
Size getTileSize() const
returns the size of a tile of the level. (0,0) if the level is not tiled.
Definition: levelinfo.hpp:104
int getTileCount() const
returns the number of tiles of the level.
Definition: levelinfo.hpp:111
Definition: exceptions.hpp:15