changeset 710:c87a1d529e13

test pngreader
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 13 Feb 2014 15:11:11 +0100
parents 6c90ce085261
children 8f62e8d5a384
files Core/FileFormats/PngReader.h UnitTestsSources/Png.cpp
diffstat 2 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Core/FileFormats/PngReader.h	Thu Feb 13 15:06:38 2014 +0100
+++ b/Core/FileFormats/PngReader.h	Thu Feb 13 15:11:11 2014 +0100
@@ -96,6 +96,11 @@
 
     void ReadFromFile(const char* filename);
 
+    void ReadFromFile(const std::string& filename)
+    {
+      ReadFromFile(filename.c_str());
+    }
+
     void ReadFromMemory(const void* buffer,
                         size_t size);
 
--- a/UnitTestsSources/Png.cpp	Thu Feb 13 15:06:38 2014 +0100
+++ b/UnitTestsSources/Png.cpp	Thu Feb 13 15:11:11 2014 +0100
@@ -112,6 +112,7 @@
     Orthanc::PngReader r;
     r.ReadFromMemory(s);
 
+    ASSERT_EQ(r.GetFormat(), Orthanc::PixelFormat_Grayscale16);
     ASSERT_EQ(r.GetWidth(), width);
     ASSERT_EQ(r.GetHeight(), height);
 
@@ -127,14 +128,17 @@
   }
 
   {
-    Toolbox::TemporaryFile tmp;
-    Toolbox::WriteFile(s, tmp.GetPath());
+    Orthanc::Toolbox::TemporaryFile tmp;
+    Orthanc::Toolbox::WriteFile(s, tmp.GetPath());
 
     Orthanc::PngReader r2;
     r2.ReadFromFile(tmp.GetPath());
 
+    ASSERT_EQ(r2.GetFormat(), Orthanc::PixelFormat_Grayscale16);
     ASSERT_EQ(r2.GetWidth(), width);
     ASSERT_EQ(r2.GetHeight(), height);
+
+    v = 0;
     for (int y = 0; y < height; y++)
     {
       uint16_t *p = reinterpret_cast<uint16_t*>((uint8_t*) r2.GetBuffer() + y * r2.GetPitch());