}
+class TargaDecodeGrayPixelRLE
+{
+TargaPacketSize m_packetSize;
+RGBAPixel m_pixel;
+TargaPacket m_packet;
+public:
+TargaDecodeGrayPixelRLE() : m_packetSize( 0 ){
+}
+void operator()( PointerInputStream& istream, RGBAPixel& pixel ){
+ if ( m_packetSize == 0 ) {
+ targa_packet_read_istream( m_packet, istream );
+ m_packetSize = targa_packet_size( m_packet );
+
+ if ( targa_packet_is_rle( m_packet ) ) {
+ istream_read_gray( istream, m_pixel );
+ }
+ }
+
+ if ( targa_packet_is_rle( m_packet ) ) {
+ pixel = m_pixel;
+ }
+ else
+ {
+ istream_read_gray( istream, pixel );
+ }
+
+ --m_packetSize;
+}
+};
+
+template<typename Flip>
+void targa_decode_rle_grayscale( PointerInputStream& istream, RGBAImage& image, const Flip& flip ){
+ TargaDecodeGrayPixelRLE decode;
+ image_decode( istream, decode, image, flip );
+}
+
class TargaDecodeRGBPixelRLE
{
TargaPacketSize m_packetSize;
return 0;
}
}
- else if ( targa_header.image_type == 10 ) {
+ else if ( targa_header.image_type == 10 || targa_header.image_type == 11 ) {
switch ( targa_header.pixel_size )
{
+ case 8:
+ targa_decode_rle_grayscale( istream, *image, flip );
+ break;
case 24:
targa_decode_rle_rgb( istream, *image, flip );
break;
targa_header_read_istream( targa_header, istream );
- if ( targa_header.image_type != 2 && targa_header.image_type != 10 && targa_header.image_type != 3 ) {
+ if ( targa_header.image_type != 2 && targa_header.image_type != 10 && targa_header.image_type != 3 && targa_header.image_type != 11 ) {
globalErrorStream() << "LoadTGA: TGA type " << targa_header.image_type << " not supported\n";
- globalErrorStream() << "LoadTGA: Only type 2 (RGB), 3 (gray), and 10 (RGB) TGA images supported\n";
+ globalErrorStream() << "LoadTGA: Only type 2 (RGB), 3 (gray), 10 (RGB), and 11 (gray) TGA images supported\n";
return 0;
}
return 0;
}
- if ( ( targa_header.pixel_size != 32 && targa_header.pixel_size != 24 )
- && targa_header.image_type != 3 ) {
- globalErrorStream() << "LoadTGA: Only 32 or 24 bit images supported\n";
+ if ( ( ( targa_header.image_type == 2 || targa_header.image_type == 10 ) && targa_header.pixel_size != 32 && targa_header.pixel_size != 24 ) ||
+ ( ( targa_header.image_type == 3 || targa_header.image_type == 11 ) && targa_header.pixel_size != 8 ) ) {
+ globalErrorStream() << "LoadTGA: Only 32, 24 or 8 bit images supported\n";
return 0;
}