|
CLAW Library (a C++ Library Absolutely Wonderful) 1.5.5
|
The type of the output buffer associated with the file when encoding RLE data. More...
#include <targa.hpp>
Public Types | |
| typedef Pixel | pixel_type |
| The type of the pixels in the input buffer. | |
| typedef pixel_type | pattern_type |
Public Member Functions | |
| file_output_buffer (std::ostream &os) | |
| Constructor. | |
| void | encode (unsigned int n, pattern_type pattern) |
| Code a pixel. | |
| template<typename Iterator > | |
| void | raw (Iterator first, Iterator last) |
| Write raw data int the stream. | |
| unsigned int | min_interesting () const |
| Get the minimum number of pixels needed for encoding. | |
| unsigned int | max_encodable () const |
| Get the maximum number of pixel a code can encode. | |
| void | order_pixel_bytes (const pixel_type &p) |
| template<> | |
| void | order_pixel_bytes (const pixel_type &p) |
Private Attributes | |
| std::ostream & | m_stream |
| The stream in which we write. | |
The type of the output buffer associated with the file when encoding RLE data.
Template parameters
| typedef pixel_type claw::graphic::targa::writer::file_output_buffer< Pixel >::pattern_type |
| typedef Pixel claw::graphic::targa::writer::file_output_buffer< Pixel >::pixel_type |
| claw::graphic::targa::writer::file_output_buffer< Pixel >::file_output_buffer | ( | std::ostream & | os | ) |
Constructor.
| os | The |
Definition at line 47 of file targa_writer.tpp.
: m_stream(os) { } // targa::writer::file_output_buffer::file_output_buffer()
| void claw::graphic::targa::writer::file_output_buffer< Pixel >::encode | ( | unsigned int | n, |
| pattern_type | pattern | ||
| ) |
Code a pixel.
| n | The number of time the pixel appears. |
| pattern | The value of the pixel. |
Definition at line 61 of file targa_writer.tpp.
{
assert( n <= max_encodable() );
assert( n >= min_interesting() );
unsigned char key = (n-1) | 0x80;
m_stream << key;
order_pixel_bytes( pattern );
} // targa::writer::file_output_buffer::encode()
| unsigned int claw::graphic::targa::writer::file_output_buffer< Pixel >::max_encodable | ( | ) | const |
Get the maximum number of pixel a code can encode.
Definition at line 126 of file targa_writer.tpp.
{
return 0x80;
} // targa::writer::file_output_buffer::max_encodable()
| unsigned int claw::graphic::targa::writer::file_output_buffer< Pixel >::min_interesting | ( | ) | const |
Get the minimum number of pixels needed for encoding.
Definition at line 115 of file targa_writer.tpp.
{
return 2;
} // targa::writer::file_output_buffer::min_interesting()
| void claw::graphic::targa::writer::file_output_buffer< claw::graphic::rgba_pixel_8 >::order_pixel_bytes | ( | const pixel_type & | p | ) |
Definition at line 52 of file targa_writer.cpp.
{
m_stream << p.components.blue << p.components.green
<< p.components.red << p.components.alpha;
} // targa::writer::file_output_buffer::order_pixel_bytes()
| void claw::graphic::targa::writer::file_output_buffer< Pixel >::order_pixel_bytes | ( | const pixel_type & | p | ) |
Referenced by claw::graphic::targa::writer::save_true_color().
| void claw::graphic::targa::writer::file_output_buffer< Pixel >::raw | ( | Iterator | first, |
| Iterator | last | ||
| ) |
Write raw data int the stream.
| first | Iterator on the first data. |
| last | Iterator past the last data. |
Definition at line 81 of file targa_writer.tpp.
{
unsigned int n = std::distance(first, last);
unsigned int full = n / max_encodable();
unsigned int remaining = n % max_encodable();
unsigned char key = max_encodable() - 1;
for (unsigned int i=0; i!=full; ++i)
{
m_stream << key;
for (unsigned int j=0; j!=max_encodable(); ++j, ++first)
order_pixel_bytes( *first );
}
if (remaining)
{
key = remaining - 1;
m_stream << key;
for (unsigned int j=0; j!=remaining; ++j, ++first)
order_pixel_bytes( *first );
}
} // targa::writer::file_output_buffer::raw()
std::ostream& claw::graphic::targa::writer::file_output_buffer< Pixel >::m_stream [private] |
1.7.3