comparison Framework/ImageToolbox.cpp @ 209:628201cb48c2

fix build
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 06 Nov 2020 17:44:35 +0100
parents a1c265cb2174
children cab272485c38
comparison
equal deleted inserted replaced
208:541a4aa63278 209:628201cb48c2
91 91
92 uint8_t grayscale = (2126 * static_cast<uint16_t>(r) + 92 uint8_t grayscale = (2126 * static_cast<uint16_t>(r) +
93 7152 * static_cast<uint16_t>(g) + 93 7152 * static_cast<uint16_t>(g) +
94 0722 * static_cast<uint16_t>(b)) / 10000; 94 0722 * static_cast<uint16_t>(b)) / 10000;
95 95
96 const unsigned int width = image.GetWidth();
97 const unsigned int height = image.GetHeight();
98
96 switch (image.GetFormat()) 99 switch (image.GetFormat())
97 { 100 {
98 case Orthanc::PixelFormat_Grayscale8: 101 case Orthanc::PixelFormat_Grayscale8:
99 { 102 {
100 for (unsigned int y = 0; y < image.GetHeight(); y++) 103 for (unsigned int y = 0; y < height; y++)
101 { 104 {
102 memset(image.GetRow(y), grayscale, image.GetWidth()); 105 memset(image.GetRow(y), grayscale, width);
103 } 106 }
104 107
105 break; 108 break;
106 } 109 }
107 110
108 case Orthanc::PixelFormat_RGB24: 111 case Orthanc::PixelFormat_RGB24:
109 { 112 {
110 for (unsigned int y = 0; y < image.GetHeight(); y++) 113 for (unsigned int y = 0; y < height; y++)
111 { 114 {
112 uint8_t* p = reinterpret_cast<uint8_t*>(image.GetRow(y)); 115 uint8_t* p = reinterpret_cast<uint8_t*>(image.GetRow(y));
113 for (unsigned int x = 0; x < image.GetWidth(); x++, p += 3) 116 for (unsigned int x = 0; x < width; x++, p += 3)
114 { 117 {
115 p[0] = r; 118 p[0] = r;
116 p[1] = g; 119 p[1] = g;
117 p[2] = b; 120 p[2] = b;
118 } 121 }
328 } 331 }
329 332
330 const unsigned int bytesPerPixel = source.GetBytesPerPixel(); // Corresponds to the number of channels tx (*) 333 const unsigned int bytesPerPixel = source.GetBytesPerPixel(); // Corresponds to the number of channels tx (*)
331 334
332 std::unique_ptr<Orthanc::ImageAccessor> target(Allocate(source.GetFormat(), 335 std::unique_ptr<Orthanc::ImageAccessor> target(Allocate(source.GetFormat(),
333 source.GetWidth() / 2, 336 source.GetWidth() / 2,
334 source.GetHeight() / 2)); 337 source.GetHeight() / 2));
335 338
336 for (unsigned int y = 0; y < target->GetHeight(); y++) 339 const unsigned int width = target->GetWidth();
340 const unsigned int height = target->GetHeight();
341
342 for (unsigned int y = 0; y < height; y++)
337 { 343 {
338 uint8_t* q = reinterpret_cast<uint8_t*>(target->GetRow(y)); 344 uint8_t* q = reinterpret_cast<uint8_t*>(target->GetRow(y));
339 345
340 for (unsigned int x = 0; x < target->GetWidth(); x++, q += bytesPerPixel) 346 for (unsigned int x = 0; x < width; x++, q += bytesPerPixel)
341 { 347 {
342 for (unsigned int c = 0; c < bytesPerPixel; c++) 348 for (unsigned int c = 0; c < bytesPerPixel; c++)
343 { 349 {
344 if (smooth) 350 if (smooth)
345 { 351 {
358 364
359 365
360 Orthanc::ImageAccessor* Clone(const Orthanc::ImageAccessor& accessor) 366 Orthanc::ImageAccessor* Clone(const Orthanc::ImageAccessor& accessor)
361 { 367 {
362 std::unique_ptr<Orthanc::ImageAccessor> result(Allocate(accessor.GetFormat(), 368 std::unique_ptr<Orthanc::ImageAccessor> result(Allocate(accessor.GetFormat(),
363 accessor.GetWidth(), 369 accessor.GetWidth(),
364 accessor.GetHeight())); 370 accessor.GetHeight()));
365 Embed(*result, accessor, 0, 0); 371 Embed(*result, accessor, 0, 0);
366 372
367 return result.release(); 373 return result.release();
368 } 374 }
369 375
370 376
371 Orthanc::ImageAccessor* Render(ITiledPyramid& pyramid, 377 Orthanc::ImageAccessor* Render(ITiledPyramid& pyramid,
372 unsigned int level) 378 unsigned int level)
373 { 379 {
374 std::unique_ptr<Orthanc::ImageAccessor> result(Allocate(pyramid.GetPixelFormat(), 380 std::unique_ptr<Orthanc::ImageAccessor> result(Allocate(pyramid.GetPixelFormat(),
375 pyramid.GetLevelWidth(level), 381 pyramid.GetLevelWidth(level),
376 pyramid.GetLevelHeight(level))); 382 pyramid.GetLevelHeight(level)));
377 383
378 LOG(INFO) << "Rendering a tiled image of size " << result->GetWidth() << "x" << result->GetHeight(); 384 LOG(INFO) << "Rendering a tiled image of size "
379 385 << result->GetWidth() << "x" << result->GetHeight();
380 for (unsigned int y = 0; y < result->GetHeight(); y += pyramid.GetTileHeight()) 386
381 { 387 const unsigned int width = result->GetWidth();
382 for (unsigned int x = 0; x < result->GetWidth(); x += pyramid.GetTileWidth()) 388 const unsigned int height = result->GetHeight();
389
390 for (unsigned int y = 0; y < height; y += pyramid.GetTileHeight())
391 {
392 for (unsigned int x = 0; x < width; x += pyramid.GetTileWidth())
383 { 393 {
384 std::unique_ptr<Orthanc::ImageAccessor> tile(pyramid.DecodeTile(level, 394 std::unique_ptr<Orthanc::ImageAccessor> tile(pyramid.DecodeTile(level,
385 x / pyramid.GetTileWidth(), 395 x / pyramid.GetTileWidth(),
386 y / pyramid.GetTileHeight())); 396 y / pyramid.GetTileHeight()));
387 Embed(*result, *tile, x, y); 397 Embed(*result, *tile, x, y);