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

void PoDoFo::PdfCanvas::AddColorResource ( const PdfColor rColor ) [inherited]

Register a colourspace for a (separation) colour in the resource dictionary of this page or XObbject so that it can be used for any following drawing operations.

Parameters:
rColorreference to the PdfColor

Definition at line 48 of file PdfCanvas.cpp.

References PoDoFo::PdfCanvas::AddResource(), PoDoFo::PdfColor::BuildColorSpace(), PoDoFo::ePdfColorSpace_CieLab, PoDoFo::ePdfColorSpace_DeviceCMYK, PoDoFo::ePdfColorSpace_DeviceGray, PoDoFo::ePdfColorSpace_DeviceRGB, PoDoFo::ePdfColorSpace_Separation, PoDoFo::ePdfError_InvalidHandle, PoDoFo::PdfColor::GetColorSpace(), PoDoFo::PdfCanvas::GetContents(), PoDoFo::PdfVariant::GetDictionary(), PoDoFo::PdfDictionary::GetKey(), PoDoFo::PdfColor::GetName(), PoDoFo::PdfCanvas::GetResources(), PoDoFo::PdfDictionary::HasKey(), PODOFO_RAISE_ERROR, and PoDoFo::PdfObject::Reference().

Referenced by PoDoFo::PdfPainter::SetColor(), and PoDoFo::PdfPainter::SetStrokingColor().

{
    PdfObject* pResource = GetResources();
    
    if( !pResource )
    {
        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
    }

      switch( rColor.GetColorSpace() )
      {
            case ePdfColorSpace_Separation:
            {
                  std::string csPrefix( "ColorSpace" );
                  std::string csName = rColor.GetName();
                  std::string temp( csPrefix + csName );
            
                  if ( 
                        ! pResource->GetDictionary().HasKey( "ColorSpace" )   ||
                        ! pResource->GetDictionary().GetKey( "ColorSpace" )->GetDictionary().HasKey( csPrefix + csName )
                )
                  {
                        // Build color-spaces for separation
                PdfObject* csp = rColor.BuildColorSpace( GetContents()->GetOwner() );
 
                AddResource( csPrefix + csName, csp->Reference(), PdfName("ColorSpace") );
                  }
            }
            break;

            case ePdfColorSpace_CieLab:
            {
                  if ( 
                        ! pResource->GetDictionary().HasKey( "ColorSpace" )   ||
                        ! pResource->GetDictionary().GetKey( "ColorSpace" )->GetDictionary().HasKey( "ColorSpaceLab" )
                     )
                  {
                        // Build color-spaces for CIE-lab
                PdfObject* csp = rColor.BuildColorSpace( GetContents()->GetOwner() );

                        AddResource( "ColorSpaceCieLab", csp->Reference(), PdfName("ColorSpace") );
                  }
            }
            break;

        case ePdfColorSpace_DeviceGray:
        case ePdfColorSpace_DeviceRGB:
        case ePdfColorSpace_DeviceCMYK:
            // No colorspace needed
            default:
            break;
      }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index