Logo Search packages:      
Sourcecode: libpodofo version File versions  Download package

void PoDoFo::PdfImage::SetImageICCProfile ( PdfInputStream pStream,
long  lColorComponents,
EPdfColorSpace  eAlternateColorSpace = ePdfColorSpace_DeviceRGB 
)

Set an ICC profile for this image.

Parameters:
pStreaman input stream from which the ICC profiles data can be read
lColorComponentsthe number of colorcomponents of the ICC profile
eAlternateColorSpacean alternate colorspace to use if the ICC profile cannot be used
See also:
SetImageColorSpace to set an colorspace instead of an ICC profile for this image

Definition at line 122 of file PdfImage.cpp.

References PoDoFo::PdfDictionary::AddKey(), ColorspaceToName(), PoDoFo::PdfVecObjects::CreateObject(), PoDoFo::ePdfError_ValueOutOfRange, PoDoFo::PdfVariant::GetDictionary(), PoDoFo::PdfElement::GetObject(), PoDoFo::PdfObject::GetOwner(), PoDoFo::PdfObject::GetStream(), PODOFO_RAISE_ERROR_INFO, PoDoFo::PdfArray::push_back(), PoDoFo::PdfObject::Reference(), and PoDoFo::PdfStream::Set().

{
    // Check lColorComponents for a valid value
    if( lColorComponents != 1 &&
        lColorComponents != 3 &&  
        lColorComponents != 4 )
    {
        PODOFO_RAISE_ERROR_INFO( ePdfError_ValueOutOfRange, "SetImageICCProfile lColorComponents must be 1,3 or 4!" );
    }

    // Create a colorspace object
    PdfObject* pIccObject = this->GetObject()->GetOwner()->CreateObject();
    pIccObject->GetDictionary().AddKey( PdfName("Alternate"), PdfName( ColorspaceToName( eAlternateColorSpace ) ) );
    pIccObject->GetDictionary().AddKey( PdfName("N"), static_cast<pdf_int64>(lColorComponents) );
    pIccObject->GetStream()->Set( pStream );
    
    // Add the colorspace to our image
    PdfArray array;
    array.push_back( PdfName("ICCBased") );
    array.push_back( pIccObject->Reference() );
    this->GetObject()->GetDictionary().AddKey( PdfName("ColorSpace"), array );
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index