Skip to content

Commit c09af57

Browse files
committed
Fixed #15: load uncompressed .hdr if scanline header does not match run-length encoding
1 parent 8473779 commit c09af57

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

dependencies/pic/pic_input_file.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,10 @@ void pic::pic_input_file::read_scanline(pixel* scanline, std::size_t length)
306306
throw pic::runtime_error(std::string("pic: error: ") + __FUNCTION__);
307307
}
308308
if ((header[0] != 2) || (header[1] != 2)) {
309-
#ifdef PIC_DEBUG
310-
std::cerr << istream_.tellg() << ": " << "error: " << std::endl;
311-
#endif
312-
throw pic::runtime_error(std::string("pic: error: ") + __FUNCTION__);
309+
// Uncompressed format (not run-length encoded)
310+
memcpy(scanline, header, sizeof(pixel));
311+
istream_.read(reinterpret_cast<char*>(&scanline[1]), (length - 1) * sizeof(pixel));
312+
return;
313313
}
314314
std::size_t scanline_length = (header[2] << 8) | header[3];
315315
if (scanline_length != length) {

0 commit comments

Comments
 (0)