#include <Header.hh>
Collaboration diagram for image::CHeader:
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.
|
default construct will construct an empty image header.
|
|
this constructor will initialize everything.
00052 { 00053 Assign( width, height, channel_per_pixel, bit_per_channel, 00054 colour, x_resolution, y_resolution ) ; 00055 assert( IsValid( ) ) ; 00056 } |
|
destructor do nothing.
00061 { 00062 } |
|
returns the number of columns of pixel of the image.
00104 { 00105 assert( IsValid( ) ) ; 00106 return m_width ; 00107 } |
|
returns the number of rows of pixel of the image.
00112 { 00113 assert( IsValid( ) ) ; 00114 return m_height ; 00115 } |
|
returns the colour space of the image.
00129 { 00130 assert( IsValid( ) ) ; 00131 return m_colour ; 00132 } |
|
returns the number of bits per colour channel.
00137 { 00138 assert( IsValid( ) ) ; 00139 return m_bit_per_channel ; 00140 } |
|
returns the number of channel per pixel.
00145 { 00146 assert( IsValid( ) ) ; 00147 return m_channel_per_pixel ; 00148 } |
|
returns the horizonal resolution of the image, in dot-per-inch.
00153 { 00154 assert( IsValid( ) ) ; 00155 return m_x_resolution ; 00156 } |
|
returns the vertical resolution of the image, in dot-per-inch.
00161 { 00162 assert( IsValid( ) ) ; 00163 return m_y_resolution ; 00164 } |
|
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 } |
|
return true if the image is empty, otherwise false.
00121 { 00122 assert( IsValid( ) ) ; 00123 return m_height == 0 ; 00124 } |
|
this function will change the image to an empty image.
|
|
this function will calculate the width of the image in 1/72 inch units. assertion will fail if the image is empty.
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 } |
|
this function will calculate the height of the image in 1/72 inch units. assertion will fail if the image is empty.
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 } |
|
image dimension, in pixels. |
|
image dimension, in pixels. |
|
image resolution, in dot-per-inch. |
|
image resolution, in dot-per-inch. |
|
colour component/channel per pixel
|
|
number of bit per component/channel
|
|
colour space. e.g. RGB, grayscale
|