comparison OrthancFramework/UnitTestsSources/ImageTests.cpp @ 4642:69bbb4bd35cb

PngWriter recreates a new libpng context for each encoding
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 28 Apr 2021 11:22:39 +0200
parents d9473bd5ed43
children 7053502fbf97
comparison
equal deleted inserted replaced
4641:b02dc8303cf6 4642:69bbb4bd35cb
519 } 519 }
520 } 520 }
521 } 521 }
522 #endif 522 #endif
523 } 523 }
524
525
526 TEST(PngWriter, Gray16Then8)
527 {
528 Orthanc::Image image16(Orthanc::PixelFormat_Grayscale16, 32, 32, false);
529 Orthanc::Image image8(Orthanc::PixelFormat_Grayscale8, 32, 32, false);
530
531 memset(image16.GetBuffer(), 0, image16.GetHeight() * image16.GetPitch());
532 memset(image8.GetBuffer(), 0, image8.GetHeight() * image8.GetPitch());
533
534 {
535 Orthanc::PamWriter w;
536 std::string s;
537 Orthanc::IImageWriter::WriteToMemory(w, s, image16);
538 Orthanc::IImageWriter::WriteToMemory(w, s, image8); // No problem here
539 }
540
541 {
542 Orthanc::PamWriter w;
543 std::string s;
544 Orthanc::IImageWriter::WriteToMemory(w, s, image8);
545 Orthanc::IImageWriter::WriteToMemory(w, s, image16); // No problem here
546 }
547
548 {
549 Orthanc::PngWriter w;
550 std::string s;
551 Orthanc::IImageWriter::WriteToMemory(w, s, image8);
552 Orthanc::IImageWriter::WriteToMemory(w, s, image16); // No problem here
553 }
554
555 {
556 // The following call leads to "Invalid read of size 1" in Orthanc <= 1.9.2
557 Orthanc::PngWriter w;
558 std::string s;
559 Orthanc::IImageWriter::WriteToMemory(w, s, image16);
560 Orthanc::IImageWriter::WriteToMemory(w, s, image8); // Problem here
561 }
562 }