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.
00072 : m_image(img) 00073 { 00074 00075 } // 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, claw::graphic::targa::file_structure::rle_true_color, save_rle_true_color(), save_true_color(), claw::graphic::targa::file_structure::true_color, and claw::graphic::image::width().
00098 { 00099 header h( m_image.width(), m_image.height() ); 00100 00101 if (rle) 00102 h.image_type = rle_true_color; 00103 else 00104 h.image_type = true_color; 00105 00106 os.write( reinterpret_cast<char*>(&h), sizeof(header) ); 00107 00108 if (rle) 00109 save_rle_true_color(os); 00110 else 00111 save_true_color(os); 00112 00113 footer f; 00114 os.write( reinterpret_cast<char*>(&f), sizeof(footer) ); 00115 } // 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().
00136 { 00137 rle32_encoder encoder; 00138 rle32_encoder::output_buffer_type output_buffer(os); 00139 00140 for ( unsigned int y=0; y!=m_image.height(); ++y ) 00141 encoder.encode( m_image[y].begin(), m_image[y].end(), output_buffer ); 00142 } // 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().
00123 { 00124 file_output_buffer<rgba_pixel_8> output_buffer(os); 00125 00126 for (const_iterator it=m_image.begin(); it!=m_image.end(); ++it) 00127 output_buffer.order_pixel_bytes(*it); 00128 } // 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().