comparison UnitTestsSources/ImageTests.cpp @ 3834:219de90c1f43

Added a flag to use an extra buffer in PamReader to ensure (malloc-like) alignment of the image buffer. This flag is NOT turned on by default and, in Orthanc, is only used by the Unit tests.
author Benjamin Golinvaux <bgo@osimis.io>
date Wed, 15 Apr 2020 16:58:28 +0200
parents 94f4a18a79cc
children
comparison
equal deleted inserted replaced
3831:83ea6939293d 3834:219de90c1f43
408 } 408 }
409 } 409 }
410 } 410 }
411 411
412 { 412 {
413 // true means "enforce alignment by using a temporary buffer"
414 Orthanc::PamReader r(true);
415 r.ReadFromMemory(s);
416
417 ASSERT_EQ(r.GetFormat(), Orthanc::PixelFormat_Grayscale16);
418 ASSERT_EQ(r.GetWidth(), width);
419 ASSERT_EQ(r.GetHeight(), height);
420
421 v = 0;
422 for (unsigned int y = 0; y < height; y++)
423 {
424 const uint16_t* p = reinterpret_cast<const uint16_t*>
425 ((const uint8_t*)r.GetConstBuffer() + y * r.GetPitch());
426 ASSERT_EQ(p, r.GetConstRow(y));
427 for (unsigned int x = 0; x < width; x++, p++, v++)
428 {
429 ASSERT_EQ(v, *p);
430 }
431 }
432 }
433
434 {
413 Orthanc::TemporaryFile tmp; 435 Orthanc::TemporaryFile tmp;
414 tmp.Write(s); 436 tmp.Write(s);
415 437
416 Orthanc::PamReader r2; 438 Orthanc::PamReader r2;
417 r2.ReadFromFile(tmp.GetPath()); 439 r2.ReadFromFile(tmp.GetPath());
430 { 452 {
431 ASSERT_EQ(*p, v); 453 ASSERT_EQ(*p, v);
432 } 454 }
433 } 455 }
434 } 456 }
435 } 457
458 {
459 Orthanc::TemporaryFile tmp;
460 tmp.Write(s);
461
462 // true means "enforce alignment by using a temporary buffer"
463 Orthanc::PamReader r2(true);
464 r2.ReadFromFile(tmp.GetPath());
465
466 ASSERT_EQ(r2.GetFormat(), Orthanc::PixelFormat_Grayscale16);
467 ASSERT_EQ(r2.GetWidth(), width);
468 ASSERT_EQ(r2.GetHeight(), height);
469
470 v = 0;
471 for (unsigned int y = 0; y < height; y++)
472 {
473 const uint16_t* p = reinterpret_cast<const uint16_t*>
474 ((const uint8_t*)r2.GetConstBuffer() + y * r2.GetPitch());
475 ASSERT_EQ(p, r2.GetConstRow(y));
476 for (unsigned int x = 0; x < width; x++, p++, v++)
477 {
478 ASSERT_EQ(*p, v);
479 }
480 }
481 }
482
483 }