Index: boost/gil/extension/io/formats/targa/read.hpp =================================================================== --- boost/gil/extension/io/formats/targa/read.hpp (revision 83843) +++ boost/gil/extension/io/formats/targa/read.hpp (working copy) @@ -127,7 +127,14 @@ { this->_scanline_length = this->_info._width * ( this->_info._bits_per_pixel / 8 ); - read_data< bgr8_view_t >( dst_view ); + if( this->_info._descriptor & 0x20 ) + { + read_data< bgr8_view_t >( flipped_up_down_view( dst_view ) ); + } + else + { + read_data< bgr8_view_t >( dst_view ); + } break; } @@ -135,7 +142,14 @@ { this->_scanline_length = this->_info._width * ( this->_info._bits_per_pixel / 8 ); - read_data< bgra8_view_t >( dst_view ); + if( this->_info._descriptor & 0x20 ) + { + read_data< bgra8_view_t >( flipped_up_down_view( dst_view ) ); + } + else + { + read_data< bgra8_view_t >( dst_view ); + } break; } @@ -164,12 +178,26 @@ { case 24: { - read_rle_data< bgr8_view_t >( dst_view ); + if( this->_info._descriptor & 0x20 ) + { + read_rle_data< bgr8_view_t >( flipped_up_down_view( dst_view ) ); + } + else + { + read_rle_data< bgr8_view_t >( dst_view ); + } break; } case 32: { - read_rle_data< bgra8_view_t >( dst_view ); + if( this->_info._descriptor & 0x20 ) + { + read_rle_data< bgra8_view_t >( flipped_up_down_view( dst_view ) ); + } + else + { + read_rle_data< bgra8_view_t >( dst_view ); + } break; } default: Index: boost/gil/extension/io/formats/targa/reader_backend.hpp =================================================================== --- boost/gil/extension/io/formats/targa/reader_backend.hpp (revision 83843) +++ boost/gil/extension/io/formats/targa/reader_backend.hpp (working copy) @@ -94,8 +94,10 @@ } _info._descriptor = _io_dev.read_uint8(); - if( ( _info._bits_per_pixel == 24 && _info._descriptor != 0 ) - || ( _info._bits_per_pixel == 32 && _info._descriptor != 8 ) + targa_descriptor::type pixel_type = _info._descriptor & 0xdf; + + if( ( _info._bits_per_pixel == 24 && pixel_type != 0 ) + || ( _info._bits_per_pixel == 32 && pixel_type != 8 ) ) { io_error( "Unsupported descriptor for targa file" );