Skip to content
Snippets Groups Projects
Commit 55b6a986 authored by Manuel Günther's avatar Manuel Günther
Browse files

Fixed implementation of 16 to 8 bit PNG (now I am converting, instead of...

Fixed implementation of 16 to 8 bit PNG (now I am converting, instead of casting -> I get the MSB instead of the LSB)
parent 288b4f97
No related branches found
No related tags found
1 merge request!21Resolve "16 bit PNG images are stored as big endian"
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <blitz/array.h> #include <blitz/array.h>
#include <bob.io.base/File.h> #include <bob.io.base/File.h>
#include <bob.core/array_convert.h>
/** /**
...@@ -96,7 +97,18 @@ namespace bob { namespace io { namespace image { ...@@ -96,7 +97,18 @@ namespace bob { namespace io { namespace image {
template <class T, int N> template <class T, int N>
blitz::Array<T,N> read_png(const std::string& filename){ blitz::Array<T,N> read_png(const std::string& filename){
PNGFile png(filename.c_str(), 'r'); PNGFile png(filename.c_str(), 'r');
return png.cast<T,N>(0); switch (png.type().dtype){
case bob::io::base::array::t_uint8:{
blitz::Array<uint8_t, N> image(png.read<uint8_t, N>(0));
return bob::core::array::convert<T>(image);
}
case bob::io::base::array::t_uint16:{
blitz::Array<uint16_t, N> image(png.read<uint16_t, N>(0));
return bob::core::array::convert<T>(image);
}
default:
throw std::runtime_error("The png image has a weired data type");
}
} }
template <class T, int N> template <class T, int N>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment