png_reader ensure we throw early if a file_source cannot be opened
This commit is contained in:
parent
49829bf2f6
commit
f66fe78c03
1 changed files with 3 additions and 3 deletions
|
@ -128,7 +128,7 @@ png_reader<T>::png_reader(std::string const& file_name)
|
|||
bit_depth_(0),
|
||||
color_type_(0)
|
||||
{
|
||||
|
||||
if (!source_.is_open()) throw image_reader_exception("PNG reader: cannot open file "+ file_name);
|
||||
if (!stream_) throw image_reader_exception("PNG reader: cannot open file "+ file_name);
|
||||
init();
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ png_reader<T>::png_reader(char const* data, std::size_t size)
|
|||
color_type_(0)
|
||||
{
|
||||
|
||||
if (!stream_) throw image_reader_exception("cannot open image stream");
|
||||
if (!stream_) throw image_reader_exception("PNG reader: cannot open image stream");
|
||||
init();
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ void png_reader<T>::init()
|
|||
stream_.read(reinterpret_cast<char*>(header),8);
|
||||
if ( stream_.gcount() != 8)
|
||||
{
|
||||
throw image_reader_exception("Could not read image");
|
||||
throw image_reader_exception("PNG reader: Could not read image");
|
||||
}
|
||||
int is_png=!png_sig_cmp(header,0,8);
|
||||
if (!is_png)
|
||||
|
|
Loading…
Add table
Reference in a new issue