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

image::CHeader Class Reference

image header class More...

#include <Header.hh>

Collaboration diagram for image::CHeader:

Collaboration graph
[legend]
List of all members.

Public Methods

Private Attributes


Detailed Description

image header class

this is the image header class. it contains all parameters descripting the image except the actual pixel data.

these parameters include width and height, specified in number of pixels; pixel format, specified by channel per pixel, bit per channel and colour space; image resolution, specified in dot-per-inch.

since the storage format of the pixels is not always the same, the common data among different images are extracted as the header. pixels in an image may be stored as a raw R-G-B byte array, or compressed by deflate or DCT. as a result, this class is extracted to share common code between them, and it turns out to be quite useful.

when you creates an image::CImage object, you will have to create the header first. creating the header is simple, just fill all the data to the constructor is OK:

    image::CHeader header( 256,         // width
                           256,         // height
                           3,           // channel per pixel, 3 for RGB
                           8,           // 8 bit per channel
                           CColourSpace::RGB( ),
                           72.0f,       // horizonal resolution
                           72.0f ) ;    // vertical resolution

most function in this class is just get/set function to access the data. it is nothing special here.

there are two state of this class: empty and non-empty. an empty header represents the header of an empty image. its width, height and resolution will be zero, as well as bit-per-channel and channel-per-pixel. you should not rely on the values of these when an image is considered empty. for non-empty images, they will all be set to valid values. you can use the Empty() member function to tell whether an image header is empty.

this class is PDF independent, it is serves as a helper class to contain image parameters.


Constructor & Destructor Documentation

image::CHeader::CHeader  
 

default construct will construct an empty image header.

00033 {
00034     Clear( ) ;
00035     assert( Empty( ) ) ;
00036 }

image::CHeader::CHeader int    width,
int    height,
int    channel_per_pixel,
int    bit_per_channel,
CColourSpace    colour,
double    x_resolution,
double    y_resolution
 

this constructor will initialize everything.

Parameters:
width  number of columns of pixel in the image
height  number of rows of pixel in the image
channel_per_pixel  channel per pixel. e.g. 3 for RGB
colour  colour space. see the image::CColourSpace for details.
x_resolution  horizonal resolution
y_resolution  vertical resolution
See also:
Assign()

00052 {
00053     Assign( width, height, channel_per_pixel, bit_per_channel,
00054             colour, x_resolution, y_resolution ) ;
00055     assert( IsValid( ) ) ;
00056 }

image::CHeader::~CHeader  
 

destructor do nothing.

00061 {
00062 }


Member Function Documentation

int image::CHeader::Width   const
 

returns the number of columns of pixel of the image.

00104 {
00105     assert( IsValid( ) ) ;
00106     return m_width ;
00107 }

int image::CHeader::Height   const
 

returns the number of rows of pixel of the image.

00112 {
00113     assert( IsValid( ) ) ;
00114     return m_height ;
00115 }

const CColourSpace image::CHeader::ColourSpace   const
 

returns the colour space of the image.

00129 {
00130     assert( IsValid( ) ) ;
00131     return m_colour ;
00132 }

int image::CHeader::BitPerChannel   const
 

returns the number of bits per colour channel.

00137 {
00138     assert( IsValid( ) ) ;
00139     return m_bit_per_channel ;
00140 }

int image::CHeader::ChannelPerPixel   const
 

returns the number of channel per pixel.

00145 {
00146     assert( IsValid( ) ) ;
00147     return m_channel_per_pixel ;
00148 }

double image::CHeader::XResolution   const
 

returns the horizonal resolution of the image, in dot-per-inch.

00153 {
00154     assert( IsValid( ) ) ;
00155     return m_x_resolution ;
00156 }

double image::CHeader::YResolution   const
 

returns the vertical resolution of the image, in dot-per-inch.

00161 {
00162     assert( IsValid( ) ) ;
00163     return m_y_resolution ;
00164 }

void image::CHeader::Assign int    width,
int    height,
int    channel_per_pixel,
int    bit_per_channel,
CColourSpace    colour,
double    x_resolution,
double    y_resolution
 

this function will (re)initialize all members by the parameters. please see the ructor for details.

00071 {
00072     assert( width >= 0 ) ;
00073     assert( height >= 0 ) ;
00074     assert( channel_per_pixel >= 0 ) ;
00075     assert( bit_per_channel >= 0 ) ;
00076     assert( x_resolution >= 0 ) ;
00077     assert( y_resolution >= 0 ) ;
00078     
00079     // swap and assign
00080     m_width                 = width ;
00081     m_height                = height ;
00082     m_x_resolution          = x_resolution ;
00083     m_y_resolution          = y_resolution ;
00084     m_channel_per_pixel     = channel_per_pixel ;
00085     m_bit_per_channel       = bit_per_channel ;
00086     m_colour                = colour ;
00087 
00088     assert( IsValid( ) ) ;
00089 }

bool image::CHeader::Empty   const
 

return true if the image is empty, otherwise false.

See also:
Clear()

00121 {
00122     assert( IsValid( ) ) ;
00123     return m_height == 0 ;
00124 }

void image::CHeader::Clear  
 

this function will change the image to an empty image.

Postcondition:
Empty() return true.
See also:
Empty()

00096 {
00097     Assign( 0, 0, 0, 0, CColourSpace( ), 0, 0 ) ;
00098     assert( Empty( ) ) ;
00099 }

double image::CHeader::RealWidth   const
 

this function will calculate the width of the image in 1/72 inch units. assertion will fail if the image is empty.

Precondition:
Empty() returns true.

00171 {
00172     // if the image is empty, it will divide by zero.
00173     assert( !Empty( ) ) ;
00174     return m_width / m_x_resolution * 72.0f ;
00175 }

double image::CHeader::RealHeight   const
 

this function will calculate the height of the image in 1/72 inch units. assertion will fail if the image is empty.

Precondition:
Empty() returns true.

00182 {
00183     // if the image is empty, it will divide by zero.
00184     assert( !Empty( ) ) ;
00185     return m_height / m_y_resolution * 72.0f ;
00186 }


Member Data Documentation

int image::CHeader::m_width [private]
 

image dimension, in pixels.

int image::CHeader::m_height [private]
 

image dimension, in pixels.

double image::CHeader::m_x_resolution [private]
 

image resolution, in dot-per-inch.

double image::CHeader::m_y_resolution [private]
 

image resolution, in dot-per-inch.

int image::CHeader::m_channel_per_pixel [private]
 

colour component/channel per pixel

int image::CHeader::m_bit_per_channel [private]
 

number of bit per component/channel

CColourSpace image::CHeader::m_colour [private]
 

colour space. e.g. RGB, grayscale


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