#include <Image.hh>
Inheritance diagram for pdf::graph::CImage:
an image is a PDF XObject that holds an array of pixel and information about its format. this class represent a PDF image XObject. it actually contain the pixels. a document can have multiple instance of a single image, with different transformation (such as scaling and position). such instances are represented by the page::CXObjInst class.
an image is a resource (as all XObjects do), so it must be added to the document before use.
|
constructor initialize the object. an PDF image XObject contains the actual image data (stored in image::CImage) and its filter.
|
|
destructor does nothing
00056 { 00057 } |
|
virtual copy constructor. Implements pdf::core::CObject.
00062 { 00063 return new CImage( *this ) ; 00064 } |
|
write the resource to the PDF file
Implements pdf::common::CResource.
00128 { 00129 return file.AddObj( new core::CProxyObj( this ) ) ; 00130 } |
|
gets the underlying image container. it will be the same as the one passed to the constructor if it is not modified.
00080 { 00081 return m_image ; 00082 } |
|
the derived classes should override this function in order to provide the stream data. the prototype of this function is strange, but it allows the the derived classes to return a constrant reference of its own vector, such that a data copy can be avoided. in other cases, the derived classes can put the stream data to the output vector and return it.
Implements pdf::core::CStream.
|
|
this function will add the necessary fields to the stream dictionary. these fields include image width, height, colour space etc. they are handled by the CImgBase::MakeDictionary( ) function.
00137 { 00138 CImgBase::MakeDictionary( dict ) ; 00139 00140 if ( m_filter != none ) 00141 dict.AddPair( "Filter", FilterName( m_filter ) ) ; 00142 } |
|
this function will encode the image using the DCT filter. according to the PDF spec, the whole JPEG image file should be stored in the image xobject stream, including the JPEG image header. so this function will simple call the CJpegEncoder class to encode the image in a string stream. then copy the string stream to the output byte vector.
00101 { 00102 using namespace std ; 00103 00104 // encode the image into a string stream 00105 stringstream str ; 00106 image::CJpegEncoder jpeg ; 00107 jpeg.Encode( m_image, str.rdbuf( ) ) ; 00108 00109 // copy the string stream to the output byte vector 00110 output.assign( istreambuf_iterator<char>( str ), 00111 istreambuf_iterator<char>( ) ) ; 00112 00113 return output ; 00114 } |
|
this function will encode the image using the deflate filter. the PDF spec said that only the pixels should be put in the image xobject stream. it is not the same as the DCT filter, which includes the whole image file to the stream.
00122 { 00123 zlib::Compress( m_image.Pixels( ), output ) ; 00124 return output ; 00125 } |
|
helper functions to lookup the filter name for a given filter enum.
00147 { 00148 assert( filter >= inflate || filter < none ) ; 00149 00150 static const std::string table[] = 00151 { 00152 "FlateDecode", 00153 "DCTDecode" 00154 } ; 00155 00156 return table[filter] ; 00157 } |
|
the real image object
|
|
the filter
|