Bugfix for incorrect header check for jpg textures

This commit is contained in:
Mark Vejvoda 2010-03-26 05:45:46 +00:00
parent 9bca65faa3
commit 1e519fedbe

View File

@ -72,7 +72,10 @@ Pixmap2D* JPGReader::read(ifstream& is, const string& path, Pixmap2D* ret) const
uint8 * buffer = new uint8[length];
is.read((char*)buffer, length);
//Check buffer (weak jpeg check)
if (buffer[0] != 0x46 || buffer[1] != 0xA0) {
//if (buffer[0] != 0x46 || buffer[1] != 0xA0) {
// Proper header check found from: http://www.fastgraph.com/help/jpeg_header_format.html
if (buffer[0] != 0xFF || buffer[1] != 0xD8) {
std::cout << "0 = [" << std::hex << (int)buffer[0] << "] 1 = [" << std::hex << (int)buffer[1] << "]" << std::endl;
delete[] buffer;
std::cout << "Returning NULL jpeg" << std::endl;
return NULL;