Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

image::CImage Class Reference

a simple image class More...

#include <Image.hh>

Collaboration diagram for image::CImage:

Collaboration graph
[legend]
List of all members.

Public Types

Public Methods

Private Attributes


Detailed Description

a simple image class

the CImage class is designed to be a very simple wrapper of raw pixels. it has no reference counting. it has no function to load from all file formats. it just stores pixels, pixel format and dimension.

pixels are stored as a vector of bytes (unsigned char). dimension and everything like those is stored in the image::CHeader object. the format of the pixel in the byte array depends on the parameters in the header.

like image::CHeader, this class is totally PDF independent. it serves only as a container of all image data.

an CImage object has two states: empty or non-empty. an empty image contains no image data, while a non-empty image contains valid image data. the class will assert that the image data is in a consistant state. you can use the Empty() member function to tell if an image is empty.


Member Typedef Documentation

typedef std::vector<unsigned char> image::CImage::CPixelVec
 

type for pixel data

typedef CPixelVec::const_iterator image::CImage::iterator
 

type to iterate the pixel data


Constructor & Destructor Documentation

image::CImage::CImage  
 

default constructor constructs an empty image.

00036 {
00037     assert( Empty( ) ) ;
00038 }

image::CImage::CImage const CHeader   header,
const CPixelVec   pixels
 

constructor to initialize everything.

00043 {
00044     assert( !header.Empty( ) ) ;
00045     assert( !pixels.empty( ) ) ;
00046 
00047     Assign( header, pixels ) ;
00048     assert( !Empty( ) ) ;
00049 }

image::CImage::~CImage  
 

the destructor will clean up the pixels.

00054 {
00055     assert( IsValid( ) ) ;
00056 }


Member Function Documentation

void image::CImage::SwapAssign const CHeader   header,
CPixelVec   pixels
 

this function is provided to allow fast assignment to the image's pixels. no deep copy is done here, just swap. this function cannot be used to make the image empty, use Clear() instead.

Precondition:
width, height and pixels are valid values. i.e. they are referring to a non-empty image.
Postcondition:
just like assign() except "pixels" will be empty.
See also:
Clear()

00068 {
00069     assert( !header.Empty( ) ) ;
00070     assert( !pixels.empty( ) ) ;
00071 
00072     // clear our own before swapping, such that "m_pixels" will be empty
00073     Clear( ) ;
00074     
00075     // swap and assign
00076     m_header = header ;
00077     m_pixels.swap( pixels ) ;
00078 
00079     assert( !Empty( ) ) ;
00080 }

void image::CImage::SwapPixels CPixelVec   pixels
 

like SwapAssign(), this function is provided for fast assignment too. it does the opposite of SwapAssign().

Precondition:
*this is a non-empty image object. "pixels" is whatever.
Postcondition:
*this is an empty image object. "pixels" is the original pixel data of the object.

00090 {
00091     assert( !Empty( ) ) ;
00092 
00093     m_pixels.swap( pixels ) ;
00094     m_header.Clear( ) ;
00095 
00096     assert( Empty( ) ) ;
00097 }

void image::CImage::Assign const CHeader   header,
const CPixelVec   pixels
 

this function will re-initialize the object after it is constructed.

00129 {
00130     assert( !header.Empty( ) ) ;
00131     assert( !pixels.empty( ) ) ;
00132     assert( IsValid( ) ) ;
00133 
00134     m_header    = header ;
00135     m_pixels    = pixels ;
00136 
00137     assert( !Empty( ) ) ;
00138 }

void image::CImage::Clear  
 

to make the image empty. you must not use Assign() or SwapAssign() to make the image empty.

00103 {
00104     assert( IsValid( ) ) ;
00105     m_pixels.clear( ) ;
00106     assert( Empty( ) ) ;
00107 }


Member Data Documentation

CHeader image::CImage::m_header [private]
 

image header

CPixelVec image::CImage::m_pixels [private]
 

pixel array


The documentation for this class was generated from the following files:
Generated on Sun Feb 2 09:17:08 2003 for libpdf++ by doxygen1.2.16