comparison Framework/Algorithms/PyramidReader.cpp @ 154:32a94bbb7d05

merge
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 08 Oct 2018 12:12:39 +0200
parents a0f9a3df1110
children 6b8ccfc02051
comparison
equal deleted inserted replaced
153:b798d200ac90 154:32a94bbb7d05
59 { 59 {
60 // Bottom overflow 60 // Bottom overflow
61 assert(tileY_ * that_.sourceTileHeight_ < that_.levelHeight_); 61 assert(tileY_ * that_.sourceTileHeight_ < that_.levelHeight_);
62 62
63 unsigned int bottom = that_.levelHeight_ - tileY_ * that_.sourceTileHeight_; 63 unsigned int bottom = that_.levelHeight_ - tileY_ * that_.sourceTileHeight_;
64 Orthanc::ImageAccessor a = decoded_->GetRegion(0, bottom, 64 Orthanc::ImageAccessor a;
65 that_.sourceTileWidth_, 65 decoded_->GetRegion(a, 0, bottom,
66 that_.sourceTileHeight_ - bottom); 66 that_.sourceTileWidth_,
67 that_.sourceTileHeight_ - bottom);
67 ImageToolbox::Set(a, 68 ImageToolbox::Set(a,
68 that_.parameters_.GetBackgroundColorRed(), 69 that_.parameters_.GetBackgroundColorRed(),
69 that_.parameters_.GetBackgroundColorGreen(), 70 that_.parameters_.GetBackgroundColorGreen(),
70 that_.parameters_.GetBackgroundColorBlue()); 71 that_.parameters_.GetBackgroundColorBlue());
71 72
75 { 76 {
76 // Right overflow 77 // Right overflow
77 assert(tileX_ * that_.sourceTileWidth_ < that_.levelWidth_); 78 assert(tileX_ * that_.sourceTileWidth_ < that_.levelWidth_);
78 79
79 unsigned int right = that_.levelWidth_ - tileX_ * that_.sourceTileWidth_; 80 unsigned int right = that_.levelWidth_ - tileX_ * that_.sourceTileWidth_;
80 Orthanc::ImageAccessor a = decoded_->GetRegion(right, 0, 81 Orthanc::ImageAccessor a;
81 that_.sourceTileWidth_ - right, 82 decoded_->GetRegion(a, right, 0,
82 that_.sourceTileHeight_); 83 that_.sourceTileWidth_ - right,
84 that_.sourceTileHeight_);
83 ImageToolbox::Set(a, 85 ImageToolbox::Set(a,
84 that_.parameters_.GetBackgroundColorRed(), 86 that_.parameters_.GetBackgroundColorRed(),
85 that_.parameters_.GetBackgroundColorGreen(), 87 that_.parameters_.GetBackgroundColorGreen(),
86 that_.parameters_.GetBackgroundColorBlue()); 88 that_.parameters_.GetBackgroundColorBlue());
87 } 89 }
281 return NULL; 283 return NULL;
282 } 284 }
283 } 285 }
284 286
285 287
286 Orthanc::ImageAccessor PyramidReader::GetDecodedTile(unsigned int tileX, 288 void PyramidReader::GetDecodedTile(Orthanc::ImageAccessor& target,
287 unsigned int tileY) 289 unsigned int tileX,
290 unsigned int tileY)
288 { 291 {
289 if (tileX * targetTileWidth_ >= levelWidth_ || 292 if (tileX * targetTileWidth_ >= levelWidth_ ||
290 tileY * targetTileHeight_ >= levelHeight_) 293 tileY * targetTileHeight_ >= levelHeight_)
291 { 294 {
292 // Accessing a tile out of the source image 295 // Accessing a tile out of the source image
293 return GetOutsideTile(); 296 GetOutsideTile().GetReadOnlyAccessor(target);
294 } 297 }
295 298 else
296 SourceTile& source = AccessSourceTile(MapTargetToSourceLocation(tileX, tileY)); 299 {
297 const Orthanc::ImageAccessor& tile = source.GetDecodedTile(); 300 SourceTile& source = AccessSourceTile(MapTargetToSourceLocation(tileX, tileY));
298 301 const Orthanc::ImageAccessor& tile = source.GetDecodedTile();
299 CheckTileSize(tile); 302
300 303 CheckTileSize(tile);
301 assert(sourceTileWidth_ % targetTileWidth_ == 0 && 304
302 sourceTileHeight_ % targetTileHeight_ == 0); 305 assert(sourceTileWidth_ % targetTileWidth_ == 0 &&
303 306 sourceTileHeight_ % targetTileHeight_ == 0);
304 unsigned int xx = tileX % (sourceTileWidth_ / targetTileWidth_); 307
305 unsigned int yy = tileY % (sourceTileHeight_ / targetTileHeight_); 308 unsigned int xx = tileX % (sourceTileWidth_ / targetTileWidth_);
306 309 unsigned int yy = tileY % (sourceTileHeight_ / targetTileHeight_);
307 const uint8_t* bytes = 310
308 reinterpret_cast<const uint8_t*>(tile.GetConstRow(yy * targetTileHeight_)) + 311 const uint8_t* bytes =
309 GetBytesPerPixel(tile.GetFormat()) * xx * targetTileWidth_; 312 reinterpret_cast<const uint8_t*>(tile.GetConstRow(yy * targetTileHeight_)) +
310 313 GetBytesPerPixel(tile.GetFormat()) * xx * targetTileWidth_;
311 Orthanc::ImageAccessor region; 314
312 region.AssignReadOnly(tile.GetFormat(), 315 target.AssignReadOnly(tile.GetFormat(),
313 targetTileWidth_, 316 targetTileWidth_,
314 targetTileHeight_, 317 targetTileHeight_,
315 tile.GetPitch(), bytes); 318 tile.GetPitch(), bytes);
316 319 }
317 return region;
318 } 320 }
319 } 321 }