claw::graphic::bitmap::reader::pixel1_to_pixel32 Class Reference

Functor converting a 1bpp buffer to a 32bpp buffer. More...

List of all members.

Public Member Functions

void operator() (scanline &dest, const char *src, const color_palette_type &palette) const
 Convert a bitset array to a pixel32 scanline.

Detailed Description

Functor converting a 1bpp buffer to a 32bpp buffer.

Definition at line 219 of file bitmap.hpp.


Member Function Documentation

void claw::graphic::bitmap::reader::pixel1_to_pixel32::operator() ( scanline dest,
const char *  src,
const color_palette_type palette 
) const

Convert a bitset array to a pixel32 scanline.

Parameters:
dest (out) Filled scanline.
src Pixel array to convert.
palette Color palette.
Precondition:
palette.size() == 2

Definition at line 186 of file bitmap_reader.cpp.

References claw::graphic::image::scanline::begin(), and claw::graphic::image::scanline::size().

00187 {
00188   assert(palette.size() == 2);
00189 
00190   scanline::iterator it( dest.begin() );
00191   const unsigned int n = dest.size();
00192   const unsigned int byte_size = 8; // 8 bits per byte
00193   const unsigned int upper_bound = n / byte_size;
00194 
00195   for (unsigned int i=0; i!=upper_bound; ++i)
00196     for (unsigned int j=0; j!=byte_size; ++j, ++it)
00197       if ( src[i] & (0x80 >> j) )
00198         *it = palette[1];
00199       else
00200         *it = palette[0];
00201 
00202   for (unsigned int j = 0; j != (n % byte_size); ++j, ++it)
00203     if ( src[upper_bound] & (0x80 >> j) )
00204       *it = palette[1];
00205     else
00206       *it = palette[0];
00207 } // bitmap::reader::pixel1_to_pixel32()


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

Generated on 9 Nov 2009 for CLAW Library (a C++ Library Absolutely Wonderful) by  doxygen 1.6.1