Final lodepng reader fix

This commit is contained in:
Alex Zolotarev 2011-07-03 13:55:40 +03:00 committed by Alex Zolotarev
parent 282a7a576a
commit 9f1e7ebf9d
2 changed files with 10 additions and 9 deletions

View file

@ -120,24 +120,24 @@ inline void lodepng_read_and_convert_view(const char* filename,const View& view,
/// \brief Loads the image specified by the given png image file name and color-converts it into the given view.
/// Throws std::ios_base::failure if the file is not a valid PNG file, or if its dimensions don't match the ones of the view.
template <typename View>
inline void lodepng_read_and_convert_view(const char* filename,const View& view) {
detail::lodepng_reader_color_convert<default_color_converter> m(filename,default_color_converter());
inline void lodepng_read_and_convert_view(ReaderPtr<Reader> & reader,const View& view) {
detail::lodepng_reader_color_convert<default_color_converter> m(reader,default_color_converter());
m.apply(view);
}
/// \ingroup LODEPNG_IO
/// \brief Loads the image specified by the given png image file name and color-converts it into the given view.
template <typename View,typename CC>
inline void lodepng_read_and_convert_view(const std::string& filename,const View& view,CC cc) {
lodepng_read_and_convert_view(filename.c_str(),view,cc);
inline void lodepng_read_and_convert_view(ReaderPtr<Reader> & reader,const View& view,CC cc) {
lodepng_read_and_convert_view(reader,view,cc);
}
/// \ingroup LODEPNG_IO
/// \brief Loads the image specified by the given png image file name and color-converts it into the given view.
template <typename View>
inline void lodepng_read_and_convert_view(const std::string& filename,const View& view) {
lodepng_read_and_convert_view(filename.c_str(),view);
}
//template <typename View>
//inline void lodepng_read_and_convert_view(ReaderPtr<Reader> & reader,const View& view) {
// lodepng_read_and_convert_view(reader,view);
//}
/// \ingroup LODEPNG_IO
/// \brief Allocates a new image whose dimensions are determined by the given png image file, loads and color-converts the pixels into it.

View file

@ -176,7 +176,8 @@ namespace yg
{
lock();
view_t v = view(width(), height());
gil::lodepng_read_and_convert_view(GetPlatform().ReadPathForFile(fileName).c_str(), v, typename Traits::color_converter());
ReaderPtr<Reader> reader = GetPlatform().GetReader(fileName);
gil::lodepng_read_and_convert_view(reader, v, typename Traits::color_converter());
upload(&v(0, 0));
unlock();
}