This class write an image in a targa file. More...
#include <targa.hpp>
Classes | |
class | file_output_buffer |
The type of the output buffer associated with the file when encoding RLE data. More... | |
class | rle_targa_encoder |
RLE encoder for targa format. More... | |
Public Types | |
typedef rle_targa_encoder < rgba_pixel_8 > | rle32_encoder |
RLE encoder for 32 bpp targa images. | |
Public Member Functions | |
writer (const image &img) | |
Constructor. | |
writer (const image &img, std::ostream &f, bool rle) | |
Constructor. | |
void | save (std::ostream &f, bool rle) const |
Save the content of the image in a stream. | |
Private Member Functions | |
void | save_true_color (std::ostream &os) const |
Save the content of the image, without compression. | |
void | save_rle_true_color (std::ostream &os) const |
Save the content of the image, with RLE compression. | |
Private Attributes | |
const image & | m_image |
The image from which we read the data. |
This class write an image in a targa file.
Definition at line 407 of file targa.hpp.
claw::graphic::targa::writer::writer | ( | const image & | img | ) |
Constructor.
img | The image to save. |
Definition at line 71 of file targa_writer.cpp.
: m_image(img) { } // targa::writer::writer()
claw::graphic::targa::writer::writer | ( | const image & | img, | |
std::ostream & | f, | |||
bool | rle | |||
) |
Constructor.
img | The image to save. | |
f | The file in which we save the data. | |
rle | Tell if we must encode the data. |
Definition at line 85 of file targa_writer.cpp.
References claw::graphic::targa::save().
void claw::graphic::targa::writer::save | ( | std::ostream & | os, | |
bool | rle | |||
) | const |
Save the content of the image in a stream.
os | The stream in which we write. | |
rle | Tell if we must encode the data. |
Definition at line 97 of file targa_writer.cpp.
References claw::graphic::image::height(), m_image, save_rle_true_color(), save_true_color(), and claw::graphic::image::width().
{ header h( m_image.width(), m_image.height() ); if (rle) h.image_type = rle_true_color; else h.image_type = true_color; os.write( reinterpret_cast<char*>(&h), sizeof(header) ); if (rle) save_rle_true_color(os); else save_true_color(os); footer f; os.write( reinterpret_cast<char*>(&f), sizeof(footer) ); } // targa::writer::save()
void claw::graphic::targa::writer::save_rle_true_color | ( | std::ostream & | os | ) | const [private] |
Save the content of the image, with RLE compression.
os | The stream in which we write. |
Definition at line 135 of file targa_writer.cpp.
References claw::graphic::image::begin(), claw::rle_encoder< OutputBuffer >::encode(), claw::graphic::image::end(), claw::graphic::image::height(), and m_image.
Referenced by save().
{ rle32_encoder encoder; rle32_encoder::output_buffer_type output_buffer(os); for ( unsigned int y=0; y!=m_image.height(); ++y ) encoder.encode( m_image[y].begin(), m_image[y].end(), output_buffer ); } // targa::writer::save_rle_true_color()
void claw::graphic::targa::writer::save_true_color | ( | std::ostream & | os | ) | const [private] |
Save the content of the image, without compression.
os | The stream in which we write. |
Definition at line 122 of file targa_writer.cpp.
References claw::graphic::image::begin(), claw::graphic::image::end(), m_image, and claw::graphic::targa::writer::file_output_buffer< Pixel >::order_pixel_bytes().
Referenced by save().
{ file_output_buffer<rgba_pixel_8> output_buffer(os); for (const_iterator it=m_image.begin(); it!=m_image.end(); ++it) output_buffer.order_pixel_bytes(*it); } // targa::writer::save_true_color()
const image& claw::graphic::targa::writer::m_image [private] |
The image from which we read the data.
Definition at line 480 of file targa.hpp.
Referenced by save(), save_rle_true_color(), and save_true_color().