CLAW Library (a C++ Library Absolutely Wonderful) 1.5.5
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
claw::graphic::targa::writer Class Reference

This class write an image in a targa file. More...

#include <targa.hpp>

Inheritance diagram for claw::graphic::targa::writer:
claw::graphic::targa::file_structure

List of all members.

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 imagem_image
 The image from which we read the data.

Detailed Description

This class write an image in a targa file.

Author:
Julien Jorge

Definition at line 407 of file targa.hpp.


Member Typedef Documentation

RLE encoder for 32 bpp targa images.

Definition at line 466 of file targa.hpp.


Constructor & Destructor Documentation

claw::graphic::targa::writer::writer ( const image img)

Constructor.

Parameters:
imgThe 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.

Parameters:
imgThe image to save.
fThe file in which we save the data.
rleTell if we must encode the data.

Definition at line 85 of file targa_writer.cpp.

References claw::graphic::targa::save().

  : m_image(img)
{
  save(f, rle);
} // targa::writer::writer()

Member Function Documentation

void claw::graphic::targa::writer::save ( std::ostream &  os,
bool  rle 
) const

Save the content of the image in a stream.

Parameters:
osThe stream in which we write.
rleTell if we must encode the data.

Definition at line 97 of file targa_writer.cpp.

References claw::graphic::targa::file_structure::header::image_type.

{
  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.

Parameters:
osThe stream in which we write.

Definition at line 135 of file targa_writer.cpp.

References claw::rle_encoder< OutputBuffer >::encode().

{
  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.

Parameters:
osThe stream in which we write.

Definition at line 122 of file targa_writer.cpp.

References claw::graphic::targa::writer::file_output_buffer< Pixel >::order_pixel_bytes().

{
  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()

Member Data Documentation

The image from which we read the data.

Definition at line 480 of file targa.hpp.


The documentation for this class was generated from the following files: