30 #ifndef __CLAW_TARGA_HPP__
31 #define __CLAW_TARGA_HPP__
67 rle_black_and_white = 11
70 # pragma pack (push,1)
80 header(
unsigned int w,
unsigned int h );
119 unsigned char alpha()
const;
120 } image_specification;
171 static const std::string s_signature;
204 typedef color_palette<rgba_pixel_8> color_palette32;
224 template<
typename Pixel>
232 file_input_buffer( std::istream& f );
245 template<
typename Pixel>
246 class mapped_file_input_buffer:
272 template<
typename InputBuffer >
273 class rle_targa_output_buffer
280 typedef InputBuffer input_buffer_type;
283 rle_targa_output_buffer(
image& img,
bool up_down,
bool left_right );
286 void copy(
unsigned int n, input_buffer_type& buffer );
288 bool completed()
const;
291 void adjust_position(
int x);
324 template<
typename InputBuffer,
325 typename OutputBuffer = rle_targa_output_buffer<InputBuffer> >
326 class rle_targa_decoder
327 :
public rle_decoder< rgba_pixel_8, InputBuffer, OutputBuffer >
331 typedef InputBuffer input_buffer_type;
334 typedef OutputBuffer output_buffer_type;
338 read_mode( input_buffer_type& input, output_buffer_type& output );
345 rle_targa_decoder< file_input_buffer<rgba_pixel_8> > rle32_decoder;
350 rle_targa_decoder< file_input_buffer<rgb_pixel_8> > rle24_decoder;
354 typedef rle_targa_decoder< file_input_buffer<pixel16> > rle16_decoder;
358 typedef rle_targa_decoder< mapped_file_input_buffer<pixel8> >
365 void load( std::istream& f );
368 void check_if_targa( std::istream& f )
const;
373 void load_color_mapped(
const header& h, std::istream& f );
374 void load_rle_color_mapped(
const header& h, std::istream& f );
375 void load_true_color(
const header& h, std::istream& f );
376 void load_rle_true_color(
const header& h, std::istream& f );
378 template<
typename Pixel>
379 void load_color_mapped_raw
382 template<
typename Decoder>
383 void decompress_rle_color_mapped
386 template<
typename Pixel>
387 void load_true_color_raw(
const header& h, std::istream& f );
389 template<
typename Decoder>
390 void decompress_rle_true_color(
const header& h, std::istream& f );
392 template<
typename Pixel>
394 load_palette_content( std::istream& f,
color_palette32& palette )
const;
418 template<
typename Pixel>
429 void encode(
unsigned int n, pattern_type pattern );
431 template<
typename Iterator>
432 void raw( Iterator
first, Iterator last );
437 void order_pixel_bytes(
const pixel_type& p );
441 std::ostream& m_stream;
454 template<
typename Pixel>
470 writer(
const image& img, std::ostream& f,
bool rle );
472 void save( std::ostream& f,
bool rle )
const;
475 void save_true_color( std::ostream& os )
const;
476 void save_rle_true_color( std::ostream& os )
const;
480 const image& m_image;
485 targa(
unsigned int w,
unsigned int h );
487 targa( std::istream& f );
489 void save( std::ostream& os,
bool rle )
const;
498 #endif // __CLAW_TARGA_HPP__