30#ifndef __CLAW_TARGA_HPP__
31#define __CLAW_TARGA_HPP__
68 rle_black_and_white = 11
80 header(
unsigned int w,
unsigned int h);
119 unsigned char alpha()
const;
169 static const std::string s_signature;
197 typedef color_palette<rgba_pixel_8> color_palette32;
215 template <
typename Pixel>
223 file_input_buffer(std::istream& f);
235 template <
typename Pixel>
243 mapped_file_input_buffer(std::istream& f,
const color_palette32& p);
248 const color_palette32& m_palette;
260 template <
typename InputBuffer>
261 class rle_targa_output_buffer
268 typedef InputBuffer input_buffer_type;
271 rle_targa_output_buffer(
image& img,
bool up_down,
bool left_right);
274 void copy(
unsigned int n, input_buffer_type& buffer);
276 bool completed()
const;
279 void adjust_position(
int x);
311 template <
typename InputBuffer,
312 typename OutputBuffer
313 = rle_targa_output_buffer<InputBuffer> >
314 class rle_targa_decoder
315 :
public rle_decoder<rgba_pixel_8, InputBuffer, OutputBuffer>
319 typedef InputBuffer input_buffer_type;
322 typedef OutputBuffer output_buffer_type;
325 virtual void read_mode(input_buffer_type& input,
326 output_buffer_type& output);
331 typedef rle_targa_decoder<file_input_buffer<rgba_pixel_8> >
335 typedef rle_targa_decoder<file_input_buffer<rgb_pixel_8> >
339 typedef rle_targa_decoder<file_input_buffer<pixel16> > rle16_decoder;
342 typedef rle_targa_decoder<mapped_file_input_buffer<pixel8> >
349 void load(std::istream& f);
352 void check_if_targa(std::istream& f)
const;
354 void load_palette(
const header& h, std::istream& f,
355 color_palette32& palette)
const;
357 void load_color_mapped(
const header& h, std::istream& f);
358 void load_rle_color_mapped(
const header& h, std::istream& f);
359 void load_true_color(
const header& h, std::istream& f);
360 void load_rle_true_color(
const header& h, std::istream& f);
362 template <
typename Pixel>
363 void load_color_mapped_raw(
const header& h, std::istream& f,
364 const color_palette32& palette);
366 template <
typename Decoder>
367 void decompress_rle_color_mapped(
const header& h, std::istream& f,
368 const color_palette32& palette);
370 template <
typename Pixel>
371 void load_true_color_raw(
const header& h, std::istream& f);
373 template <
typename Decoder>
374 void decompress_rle_true_color(
const header& h, std::istream& f);
376 template <
typename Pixel>
377 void load_palette_content(std::istream& f,
378 color_palette32& palette)
const;
400 template <
typename Pixel>
401 class file_output_buffer
411 file_output_buffer(std::ostream& os);
414 template <
typename Iterator>
415 void raw(Iterator
first, Iterator last);
417 unsigned int min_interesting()
const;
418 unsigned int max_encodable()
const;
429 std::ostream& m_stream;
441 template <
typename Pixel>
456 writer(
const image& img, std::ostream& f,
bool rle);
458 void save(std::ostream& f,
bool rle)
const;
461 void save_true_color(std::ostream& os)
const;
462 void save_rle_true_color(std::ostream& os)
const;
466 const image& m_image;
471 targa(
unsigned int w,
unsigned int h);
473 targa(std::istream& f);
475 void save(std::ostream& os,
bool rle)
const;
481#include <claw/graphic/targa_reader.tpp>
482#include <claw/graphic/targa_writer.tpp>
This class is made to help reading istreams with a buffer.
This class is made to help reading istreams with a buffer.
Fuction object to get the first element of a std::pair.
rgba_pixel pixel_type
The type representing the colors of the pixels in the image.
void fill(const math::rectangle< int > r, const pixel_type &c)
Fill an area of the image with a given color.
image()
Constructor. Creates an image without datas.
void load(std::istream &f)
Load an image from a targa file.
reader(image &img)
Constructor.
The type of the output buffer associated with the file when encoding RLE data.
Pixel pixel_type
The type of the pixels in the input buffer.
pixel_type pattern_type
The type of the patterns to encode.
void order_pixel_bytes(const pixel_type &p)
Write a pixel in the stream and set its value in the good order.
RLE encoder for targa format.
file_output_buffer< Pixel > output_buffer_type
Type of the output buffer.
void save(std::ostream &f, bool rle) const
Save the content of the image in a stream.
rle_targa_encoder< rgba_pixel_8 > rle32_encoder
RLE encoder for 32 bpp targa images.
writer(const image &img)
Constructor.
targa(unsigned int w, unsigned int h)
Constructor. Creates an empty image.
void save(std::ostream &os, bool rle) const
Save the content of the image in a stream.
A class to help decoding run-length encoded (RLE) streams.
A class to help run-length encoding (RLE) streams.
A palette of color, for palettized images.
A class to deal with images.
Everything about image structures and processing.
rgba_pixel rgba_pixel_8
A color with 8 bits per component and an alpha channel.
Here are the design patterns.
This is the main namespace.
A class to help decoding run-length encoded (RLE) streams.
A class to help run-length encoding (RLE) streams.
Item in the developper directory.
unsigned int offset
Offset in the file.
unsigned int size
Fielf size.
unsigned short tag
Item identifier.