ColourContext Class Reference

#include <colcontx.h>

Inheritance diagram for ColourContext:

ListItem CCObject SimpleCCObject ColourContextCMYK ColourContextGreyT ColourContextHSVT ColourContextRGBT ColourContextWebRGBT List of all members.

Public Member Functions

 ColourContext (View *Scope)
 Constructor for a Colour context. This is shared code used by all derived ColourContextXXXX classes. You cannot create vanilla ColourContext objects (virtual functions abound).
virtual ~ColourContext ()
 Colour context destructor.
virtual BOOL IsDifferent (ColourContext *Other) const
 Determine if two colour contexts are not exactly equivalent.
void ConvertColour (DocColour *Source, ColourGeneric *Result)
 Converts a Colour into this colour context. The converted colour will be supplied from a cache where possible.
void ConvertColour (IndexedColour *Source, ColourGeneric *Result)
 Converts an indexed colour into this colour context. The converted colour will be supplied from a cache where possible.
void ConvertColour (ColourContext *SourceContext, ColourGeneric *SourceColour, ColourGeneric *Result)
 Converts a colour in any arbitrary colour context into this colour context. The converted colour will be supplied from a cache where possible.
virtual void ConvertToCIET (ColourGeneric *Source, DColourCIET *Result)=0
virtual void ConvertFromCIET (DColourCIET *Source, ColourGeneric *Result)=0
virtual void CreateExternalTransform ()
 Create an external transform to be used during colour conversions from RGB to the current RCS space. This function uses the Winoil CMS Manager to create the transform. Both forward and backward transforms use logical RGB descriptions.
ColourModel GetColourModel (void) const
 Determines the colour model on which this colour context is based.
virtual void GetModelName (StringBase *Result)=0
virtual BOOL GetComponentName (INT32 ComponentID, StringBase *Result, BOOL LongName=FALSE)=0
virtual UINT32 GetComponentCount ()=0
virtual BOOL SetComponentUnitGroup (UINT32 ComponentID, UnitGroup *pComponentUnitGroup)
virtual UnitGroupGetComponentUnitGroup (UINT32 ComponentID)
 Provides the UnitGroup of the given component in the ColourModel.
virtual void ApplyTint (ColourValue TintFraction, ColourGeneric *SourceAndResult)=0
virtual void ApplyShade (ColourValue XFraction, ColourValue YFraction, ColourGeneric *SourceAndResult)=0
virtual void ApplyInputFilter (ColourPlate *FilterDescription, ColourContext *DestContext, ColourGeneric *OutputColour, IndexedColour *SourceIxCol)
 All colour conversions call this function for the SOURCE context immediately before converting the colour. This gives the input colour context the chance to apply a filtering process to the colour.
virtual void ApplyOutputFilter (ColourPlate *FilterDescription, ColourContext *SourceContext, ColourGeneric *OutputColour, IndexedColour *SourceIxCol)
 All colour conversions call this function for the DEST context immediately prior to returning the converted colour to the caller. This gives the output colour context the chance to apply an output filtering process to the output colour.
void SetColourPlate (ColourPlate *NewColourPlate)
 Sets a colour separation/plate for this context.
ColourPlateGetColourPlate (void)
 Reads the colour separation/plate for this context.
ColourPlateDetachColourPlate (void)
 Detaches the ColourPlate (if any) currently attached to this ColourContext. The context will no longer use the colour plate descriptor, and will return to default colour separation/correction actions.
void ColourPlateHasChanged (void)
 Effectively flushes the caches of all colours currently cached in this ColourContext, so that on the next redraw they will re-convert.
virtual void GetWhite (ColourGeneric *Result)=0
virtual BOOL GetProfileTables (BYTE *Tables)
virtual BOOL IsDeviceContext () const
void ConvertColour (DocColour *Source, ColourPacked *Result)
 Converts a Colour into this colour context. The converted colour will be supplied from a cache where possible Scope: PRIVATE - for use only by 'friend' rendering classes: OSRenderRegion, GRenderRegion.

Static Public Member Functions

static BOOL InitColourContexts (void)
static void DeinitColourContexts (void)
static ColourContextGetGlobalDefault (ColourModel ColModel)
 Find a default colour context for a given colour model number within GLOBAL scope. This is a static function, so may be called without having to create an actual ColourContext instance.
static void GetGlobalDefaults (ColourContextArray *Destination)
 Find the default contexts used by this Scope: Pretty private. Should only need to be used by document.cpp.
static ColourContextRGBTGetCurrentForScreen (void)
 Code used by all renderers to find the current screen output context.

Protected Member Functions

virtual BOOL Init (void)
 Colour context initialiser. This is called by the ColourContextList when it wishes to add a context to the list, and makes the context ready for use. This allows the list to compare contexts, and only initialise a given context when it knows the initialisation is absolutely necessary (e.g. allocating a large chunk of memory or calculating a complex table is avoided until we are sure there are no equivalent contexts already available) This function is overridden by colour contexts which actually need to do some initialisation other than just storing a few values away.
BOOL DecrementUsage (void)
 Decrements usage-count for a colour context. This count allows us to determine when we can delete unused contexts.
void IncrementUsage (void)
 Increments usage-count for a colour context. This count allows us to determine when we can delete unused contexts.
virtual void PackColour (ColourGeneric *Source, ColourPacked *Result)
 Converts 128-bit colour representation to 32-bit packed form.
virtual void UnpackColour (ColourPacked *Source, ColourGeneric *Result)
 Converts 32-bit packed colour representation to 128-bit form.
void ConvertColourInternal (DocColour *Source, ColourGeneric *Result)
 Converts a Colour into this colour context. The converted colour will be supplied from a cache where possible.
void ConvertColourInternal (DocColour *Source, ColourPacked *Result)
 Converts a Colour into this colour context. The converted colour will be supplied from a cache where possible (this check is made by the caller function ConvertColour) Scope: PRIVATE - for use only by 'friend' rendering classes: OSRenderRegion, GRenderRegion.
PColourValue PackColour128 (ColourValue Source)
 Given a 32-bit (FIXED24) colour definition value, packs it into a 7-bit (unsigned byte) colour definition value. The value is rounded and clipped to lie within gamut (0.0 <= g <= 1.0).
void UnpackColour128 (PColourValue Source, FIXED24 *Result)
 Unpacks the packed source colour value into a FIXED24 unpacked format.
PColourValue PackColour256 (ColourValue Source)
 Given a 32-bit (FIXED24) colour definition value, packs it into an 8-bit (unsigned byte) colour definition value. The value is rounded and clipped to lie within gamut (0.0 <= g <= 1.0).
void UnpackColour256 (PColourValue Source, FIXED24 *Result)
 Unpacks the packed source colour value into a FIXED24 unpacked format.
PColourValue PackColour360 (ColourValue Source)
 Given a 32-bit (FIXED24) colour definition value, packs it into a 9-bit (0..359) colour definition value. The value is rounded and clipped to lie within gamut (0.0 <= g <= 1.0).
void UnpackColour360 (PColourValue Source, FIXED24 *Result)
 Unpacks the packed source colour value into a FIXED24 unpacked format.
virtual UnitGroup ** GetComponentUnitGroups ()=0
virtual void ConvertColourBase (ColourContext *SourceContext, ColourGeneric *Source, ColourGeneric *Result, IndexedColour *SourceIxCol=NULL)
 Converts a Colour into this colour context, from the default colour context implied by the given colour model Post-processing (as described by the attached ColourPlate object) will be applied to generate colour separations (etc) as required.

Static Protected Member Functions

static void SetGlobalDefault (ColourModel ColModel, ColourContext *Default)
 Set the default colour context for a given colour model number Scope: private - used internally by ColourContextList::InitColourContexts.

Protected Attributes

ColourContextHandle MyHandle
INT32 UsageCount
ColourModel ColModel
ColourPlateColPlate
HCMTRANSFORM CMSTransform
ViewScopeView

Static Protected Attributes

static ColourContextHandle NextColourContextHandle = 1

Static Private Attributes

static ColourContextArray GlobalDefaultContext

Friends

class DocColour
class ColourContextList
class GRenderRegion
class OSRenderRegion

Detailed Description

Definition at line 173 of file colcontx.h.


Constructor & Destructor Documentation

ColourContext::ColourContext View Scope  ) 
 

Constructor for a Colour context. This is shared code used by all derived ColourContextXXXX classes. You cannot create vanilla ColourContext objects (virtual functions abound).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/03/94
Parameters:
Scope - The view within which this context is to be used, or NULL [INPUTS] for a global (non-view-specific) context
- [OUTPUTS]
Returns:
-
Notes: The usage count for a colour context defaults to 0 ("not in use"). When using colour contexts, you should always register them with the global ColContextList object (see ColourContextList::AddContext for details)

When created, relevant conversion parameters (gamma correction etc) are passed in to the constructor.The context stores these parameters so it can quickly compare itself to another context, but it may defer creation of tables and other essential stuff until the Init() function is called (when it is added to the list of available colour contexts). Nobody but the context list can call the Init() function.

The passed-in Scope may be NULL, in which case global scope is used. However, if you're using this within the scope of any view, note that you must set up ScopeView properly or colour separated output of some colour models will be incorrect.

Returns:
Errors: -
See also:
ColourContextRGBT::ColourContextRGBT; ColourContextCMYK::ColourContextCMYK; ColourContextHSVT::ColourContextHSVT; ColourContextList::AddContext

Definition at line 215 of file colcontx.cpp.

00216 {
00217     MyHandle = NextColourContextHandle++;
00218 
00219     ScopeView = Scope;
00220 
00221     UsageCount = 0;
00222 
00223     ColPlate = NULL;
00224 
00225 PORTNOTE("other","Removed HCMTRANSFORM usage")
00226 #ifndef EXCLUDE_FROM_XARALX
00227     CMSTransform = NULL;
00228 #endif
00229     // ColourModel and Model-specific data must be dealt with in the 
00230     // constructor/Init() for the derived ColourContextXXXX class
00231 }

ColourContext::~ColourContext  )  [virtual]
 

Colour context destructor.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/03/94
Notes: This destroys any attached ColourPlate descriptor

See also:
ColourContextList::AddContext

Definition at line 250 of file colcontx.cpp.

00251 {
00252     ENSURE(UsageCount == 0, "ColourContext deleted while still in use!");
00253 
00254     if (ColPlate != NULL)
00255     {
00256         delete ColPlate;
00257         ColPlate = NULL;
00258     }
00259 
00260 #ifndef NO_XARACMS
00261     if (CMSTransform != NULL)
00262     {
00263         if (GetApplication()->GetCMSManager() != NULL)
00264             GetApplication()->GetCMSManager()->DestroyTransform(CMSTransform);
00265         CMSTransform = NULL;
00266     }
00267 #endif
00268 }


Member Function Documentation

void ColourContext::ApplyInputFilter ColourPlate FilterDescription,
ColourContext DestContext,
ColourGeneric OutputColour,
IndexedColour SourceIxCol
[virtual]
 

All colour conversions call this function for the SOURCE context immediately before converting the colour. This gives the input colour context the chance to apply a filtering process to the colour.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/1/96
Parameters:
FilterDescription - A ColourPlate describing how the colour is to be filtered [INPUTS]
DestContext - Points to the context to which the OutputColour will be converted after we return it.

OutputColour - The colour to be filtered

SourceIxCol - NULL, or the original IndexedColour which is being converted. This is used for handling spot colour separation correctly.

Parameters:
OutputColour - Will be modified as appropriate to the current colour [OUTPUTS] filtering options (see Purpose)
This is usually used to provide colour separations. Often, this function will do nothing to the output colour - generally it is only used by CMYK contexts in order to colour-separate the colour in CMYK space.

See also:
ColourContext::ConvertColourBase

Reimplemented in ColourContextCMYK.

Definition at line 851 of file colcontx.cpp.

00853 {
00854 //  ERROR3IF(FilterDescription == NULL || DestContext == NULL || OutputColour == NULL, "Illegal NULL params");
00855 //
00856 //  if (FilterDescription == NULL)
00857 //      return;
00858 //
00859 }

void ColourContext::ApplyOutputFilter ColourPlate FilterDescription,
ColourContext SourceContext,
ColourGeneric OutputColour,
IndexedColour SourceIxCol
[virtual]
 

All colour conversions call this function for the DEST context immediately prior to returning the converted colour to the caller. This gives the output colour context the chance to apply an output filtering process to the output colour.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/1/96
Parameters:
FilterDescription - A ColourPlate describing how the colour is to be filtered [INPUTS]
SourceContext - Points to the context from which the OutputColour has just been converted.

OutputColour - The colour to be filtered

SourceIxCol - NULL, or the IndexedColour which was the source of the colour being converted. This is only used for information when preparing spot colour separations.

Parameters:
OutputColour - Will be modified as appropriate to the current colour [OUTPUTS] filtering options (see Purpose)
This is usually used to provide colour separations, and may also be used to apply some colour corrections. Often, this function will do nothing to the output colour.

See also:
ColourContext::ConvertColourBase

Reimplemented in ColourContextRGBT, and ColourContextCMYK.

Definition at line 899 of file colcontx.cpp.

00901 {
00902 //  ERROR3IF(FilterDescription == NULL || SourceContext == NULL || OutputColour == NULL, "Illegal NULL params");
00903 //
00904 //  if (FilterDescription == NULL)
00905 //      return;
00906 }

virtual void ColourContext::ApplyShade ColourValue  XFraction,
ColourValue  YFraction,
ColourGeneric SourceAndResult
[pure virtual]
 

Implemented in ColourContextRGBT, ColourContextCMYK, ColourContextHSVT, and ColourContextGreyT.

virtual void ColourContext::ApplyTint ColourValue  TintFraction,
ColourGeneric SourceAndResult
[pure virtual]
 

Implemented in ColourContextRGBT, ColourContextCMYK, ColourContextHSVT, and ColourContextGreyT.

void ColourContext::ColourPlateHasChanged void   ) 
 

Effectively flushes the caches of all colours currently cached in this ColourContext, so that on the next redraw they will re-convert.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/5/96
Notes: This is achieved by generating a new unique handle for this Context. Note that after 65536 handles, we will start re-using handles, and things will look bad if we inadvertently use the same handle for 2 contexts. This is an extremely unlikely occurrence, but please do not call this function unless it is absolutely necessary, to minimise the number of handle changes that occur.

This function is automatically called whenever you change the ColourPlate attached to this context in any way.

Scope: Intended as an internal routine; also called by ColourPlate class Should not be called by anyone else

See also:
ColourContext::SetColourPlate; IndexedColour; DocColour

Definition at line 1050 of file colcontx.cpp.

01051 {
01052     // We need to change this context's "MyHandle" so that all cached colours for this
01053     // context are treated as non-cached again, and will be converted correctly for
01054     // the new output filter.
01055     MyHandle = NextColourContextHandle++;
01056 }

void ColourContext::ConvertColour DocColour Source,
ColourPacked Result
[inline]
 

Converts a Colour into this colour context. The converted colour will be supplied from a cache where possible Scope: PRIVATE - for use only by 'friend' rendering classes: OSRenderRegion, GRenderRegion.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/04/94
Parameters:
Source - A Colour to convert [INPUTS] Result - A PColourGeneric structure to recieve the resulting converted colour, as defined in this ColourContext.
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 788 of file colcontx.h.

00789 {
00790     ENSURE(UsageCount > 0, "Colour context being used when not initialised!");
00791     ConvertColourInternal(Source, Result);
00792 }

void ColourContext::ConvertColour ColourContext SourceContext,
ColourGeneric SourceColour,
ColourGeneric Result
 

Converts a colour in any arbitrary colour context into this colour context. The converted colour will be supplied from a cache where possible.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/03/94
Parameters:
SourceContext - The colour context in which the Source Colour is defined [INPUTS] Source - A ColourGeneric structure defining a colour to convert, in the given SourceContext Result - A ColourGeneric structure to recieve the resulting converted colour, as defined in this ColourContext.
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 781 of file colcontx.cpp.

00784 {
00785     ENSURE(UsageCount > 0, "Colour context being used when not initialised!");
00786 
00787     // This may look like an opportunity for optimisation, but
00788     // ConvertColourBase is actually an inline function
00789     ConvertColourBase(SourceContext, SourceColour, Result);
00790 }

void ColourContext::ConvertColour IndexedColour Source,
ColourGeneric Result
 

Converts an indexed colour into this colour context. The converted colour will be supplied from a cache where possible.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/03/94
Parameters:
Source - An IndexedColour to convert [INPUTS] Result - A ColourGeneric structure to recieve the resulting converted colour, as defined in this ColourContext.
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 699 of file colcontx.cpp.

00700 {
00701     ENSURE(UsageCount > 0, "Colour context being used when not initialised!");
00702 
00703     if (Source->Info.OCContextHandle != MyHandle)   // Uncached so convert it into the cache
00704     {
00705         // Ask the colour to get its source colour for us. If this is a Linked/Tint colour,
00706         // this could well involve getting another colour's definition, converting it, and
00707         // generally giving us an extended tour of stack city.
00708         ColourGeneric SourceColour;
00709         Source->GetSourceColour(&SourceColour);
00710 
00711         // Check if we're doing a spot colour plate. We either get the colour's source colour,
00712         // or if it shouldn't appear on the plate, we get White.
00713         if (ColPlate != NULL && !ColPlate->IsDisabled())
00714         {
00715             switch(ColPlate->GetType())
00716             {
00717                 case COLOURPLATE_SPOT:
00718                     // If we're doing a spot plate and this isn't a descendant of the spot colour
00719                     // then we must eliminate it from this plate. We must also check that it's a "true"
00720                     // spot/tint, as opposed to a tint which is really a process colour.
00721                     if ((!Source->IsADescendantOf(ColPlate->GetSpotColour())) ||
00722                         (!Source->IsSpotOrTintOfSpot()))
00723                     {
00724                         // Fill it with whatever White is defined as in the source context
00725                         GetGlobalDefault(Source->GetColourModel())->GetWhite(&SourceColour);
00726                     }
00727                     break;
00728 
00729                 case COLOURPLATE_CYAN:
00730                 case COLOURPLATE_MAGENTA:
00731                 case COLOURPLATE_YELLOW:
00732                 case COLOURPLATE_KEY:
00733                     // If we're doing a process plate, eliminate any spot colours (or tints) from it
00734                     if (Source->IsSpotOrTintOfSpot())
00735                     {
00736                         // Fill it with whatever White is defined as in the source context
00737                         GetGlobalDefault(Source->GetColourModel())->GetWhite(&SourceColour);
00738                     }
00739                     break;
00740                 default:
00741                     break;
00742             }
00743         }
00744 
00745         ConvertColourBase(GetGlobalDefault(Source->GetColourModel()),
00746                             &SourceColour, &Source->CachedColour,
00747                             Source);
00748 
00749         Source->Info.OCContextHandle  = MyHandle;
00750         Source->Info.CacheColourModel = ColModel;
00751     }
00752 
00753     // Copy the result from our cache
00754     memcpy(Result, &Source->CachedColour, sizeof(ColourGeneric));
00755 }

void ColourContext::ConvertColour DocColour Source,
ColourGeneric Result
[inline]
 

Converts a Colour into this colour context. The converted colour will be supplied from a cache where possible.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/04/94
Parameters:
Source - A Colour to convert [INPUTS] Result - A ColourGeneric structure to recieve the resulting converted colour, as defined in this ColourContext.
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 760 of file colcontx.h.

00761 {
00762     ENSURE(UsageCount > 0, "Colour context being used when not initialised!");
00763     ConvertColourInternal(Source, Result);
00764 }

void ColourContext::ConvertColourBase ColourContext SourceContext,
ColourGeneric Source,
ColourGeneric Result,
IndexedColour SourceIxCol = NULL
[protected, virtual]
 

Converts a Colour into this colour context, from the default colour context implied by the given colour model Post-processing (as described by the attached ColourPlate object) will be applied to generate colour separations (etc) as required.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/03/94
Parameters:
SourceContext - The context in which the source is defined [INPUTS]
Source - A ColourGeneric to convert

Result - A ColourGeneric structure to recieve the resulting converted colour, as defined in this ColourContext.

SourceIxCol - NULL, or a pointer to the IndexedColour we are converting. This is used only for handling spot colour separations, to determine if the colour is a given spot colour or tint thereof.

Parameters:
Result - will be returned with the converted colour [OUTPUTS]
The converted colour will be supplied from a cache where possible

Notes: It is up to the caller to update caches etc if necessary This is used as a base on which ConvertColourInternal methods are built

ColourContextCMYK overrides this base class method to provide direct passthrough of CMYK colours into a CMYK output context. (passthrough otherwise only occurs if the source & destination contexts are the same object)

Scope: private to colcontx.cpp

Returns:
Errors: -
See also:
ColourContext::ConvertColour

Reimplemented in ColourContextCMYK.

Definition at line 490 of file colcontx.cpp.

00493 {
00494 #ifndef NO_XARACMS
00495     // Last minute bodge for Composite preview of CMYK colours in RGB space
00496     // This is done here cos it's much faster, and gets around pre/post filter problems
00497     // with CMYK colours which aren't IndexedColours (like intermediate blend/gradfill DocColours)
00498     if (ColPlate != NULL && ColPlate->GetType() == COLOURPLATE_COMPOSITE &&
00499         GetColourModel() == COLOURMODEL_RGBT &&
00500         SourceContext->GetColourModel() == COLOURMODEL_CMYK)
00501     {
00502         // If it's a CMYK colour, then it's already in printer gamut, so we only apply
00503         // the backward colour correction factor to it.
00504         // Note that this means we chuck away the normal colour conversion system!
00505         XaraCMS* lpCMSMan = GetApplication()->GetCMSManager();
00506         if (lpCMSMan != NULL)
00507         {
00508             ColourCMYK Def;
00509             memcpy(&Def, Source, sizeof(ColourGeneric));
00510 
00511             lpCMSMan->ConvertColourForPaperView(&Def, (ColourRGBT *) Result);
00512             return;
00513         }
00514     }
00515 #endif
00516 
00517     // Copy the source colour into a temporary variable
00518     ColourGeneric FilteredSource;
00519     memcpy(&FilteredSource, Source, sizeof(ColourGeneric));
00520 
00521     // Call the SourceContext to allow it to pre-filter the colour. This is used to
00522     // provide colour separations and other doody features when converting CMYK colours
00523     // - when converting non-CMYK colours, this is usually done in the OutputFilter (below)
00524     if (ColPlate != NULL && !ColPlate->IsDisabled())
00525         SourceContext->ApplyInputFilter(ColPlate, this, &FilteredSource, SourceIxCol);
00526 
00527     // -----
00528     // Call levels expected:
00529     //  1 inline ConvertColour checks if can satisfy from cache
00530     //  2 function ConvertColourInternal does any short cuts it can, such
00531     //    as CMYK->CMYK passthrough
00532     //  3 Call ConvertColourBase, which
00533     //      a) Checks if in same colour model, and implements passthrough, or
00534     //      b) Converts colour properly via CIET space
00535 
00536     if (SourceContext == this)
00537     {
00538         // The SourceContext and Destination context are identical, so we can
00539         // just copy the definition directly across.
00540         memcpy(Result, &FilteredSource, sizeof(ColourGeneric));
00541     }
00542     else
00543     {
00544         DColourCIET IntermediateResult;
00545 
00546         SourceContext->ConvertToCIET(&FilteredSource, &IntermediateResult);
00547         ConvertFromCIET(&IntermediateResult, Result);
00548     }
00549 
00550 
00551     // Call the DestinationContext (derived class of this) to apply any output filtering -
00552     // non-CMYK colour conversions will separate the colour (as appropriate) here
00553     if (ColPlate != NULL && !ColPlate->IsDisabled())
00554         ApplyOutputFilter(ColPlate, SourceContext, Result, SourceIxCol);
00555 }

void ColourContext::ConvertColourInternal DocColour Source,
ColourPacked Result
[protected]
 

Converts a Colour into this colour context. The converted colour will be supplied from a cache where possible (this check is made by the caller function ConvertColour) Scope: PRIVATE - for use only by 'friend' rendering classes: OSRenderRegion, GRenderRegion.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/04/94
Parameters:
Source - A Colour to convert [INPUTS] Result - A PColourGeneric structure to recieve the resulting converted colour, as defined in this ColourContext.
- [OUTPUTS]
Returns:
-

Errors: -

See also:
ColourContext::ConvertColour

Definition at line 663 of file colcontx.cpp.

00664 {
00665     ColourGeneric NewResult;
00666     ConvertColourInternal(Source, &NewResult);  // Convert
00667 
00668     PackColour(&NewResult, Result);             // Pack the colour into Result...
00669 
00670     if (Source->Info.SourceColourModel != COLOURMODEL_INDEXED)
00671     {
00672         // And (if not an IndexedColour) update the cache
00673         Source->Info.OCContextHandle  = MyHandle;
00674         Source->Info.CacheColourModel = ColModel;
00675         memcpy(&Source->CachedColour, Result, sizeof(ColourPacked));
00676     }
00677 }

void ColourContext::ConvertColourInternal DocColour Source,
ColourGeneric Result
[protected]
 

Converts a Colour into this colour context. The converted colour will be supplied from a cache where possible.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/03/94
Parameters:
Source - A Colour to convert [INPUTS] Result - A ColourGeneric structure to recieve the resulting converted colour, as defined in this ColourContext.
- [OUTPUTS]
Returns:
-
Notes: This is used internally. It is only called by the inlined conversion functions if they fail to return a cached result
Returns:
Errors: -
See also:
ColourContext::ConvertColour

Definition at line 581 of file colcontx.cpp.

00582 {
00583     if (Source->Info.SourceColourModel == COLOURMODEL_INDEXED)
00584     {
00585         IndexedColour *SrcIndexed = Source->SourceColour.Indexed.Colour;
00586 
00587         // Convert the indexed colour to our context
00588         ConvertColour(SrcIndexed, Result);
00589 
00590         // If IndexedColour, we do NOT want the colour cached at the DocColour
00591         // level (else if the IxCol changes, we'd have to search for all related
00592         // DocCols to fix their caches... erg!)
00593         return;
00594     }
00595 
00596     // Unpack the 32-bit colour into a 128-bit structure, and then invoke the
00597     // shared internal conversion routine.
00598     ColourGeneric SourceDefn;
00599 
00600     // If this DocColour should not be separated (it's a UI colour), then disable
00601     // any active colour plate to stop it separating the output - we'll save and restore
00602     // its previous state around the call to ConvertColourBase
00603     BOOL WasDisabled = TRUE;
00604     if (ColPlate != NULL)
00605     {
00606         WasDisabled = ColPlate->IsDisabled();
00607         ColPlate->SetDisabled(!Source->IsSeparable());
00608     }
00609 
00610         // Check if we're doing a spot colour plate. We either get the colour's source colour,
00611         // or if it shouldn't appear on the plate, we get White.
00612         if (ColPlate != NULL && !ColPlate->IsDisabled() && ColPlate->GetType() == COLOURPLATE_SPOT)
00613         {
00614             // We're doing a SPOT colour plate, but this colour is a local DocColour, so
00615             // it cannot possibly be a tint on this plate, so we just return white.
00616             GetGlobalDefault(Source->GetColourModel())->GetWhite(&SourceDefn);
00617         }
00618         else
00619         {
00620             // Unpack the colour
00621             GetGlobalDefault(Source->GetColourModel())->UnpackColour(&Source->SourceColour, &SourceDefn);
00622         }
00623 
00624         // Assume that the source context is a global default. Generally, this should be true,
00625         // as all source colours should be defined in terms of logical colour models.
00626         ConvertColourBase(GetGlobalDefault(Source->GetColourModel()),
00627                             &SourceDefn, Result);
00628 
00629     // And restore the previous ColourPlate "disabled" state
00630     if (ColPlate != NULL)
00631         ColPlate->SetDisabled(WasDisabled);
00632 
00633     PackColour(Result, &Source->CachedColour);  // And update the cache
00634 
00635     // Update cache flags - I am the context in which the cache is defined
00636     Source->Info.OCContextHandle  = MyHandle;
00637     Source->Info.CacheColourModel = ColModel;
00638 }

virtual void ColourContext::ConvertFromCIET DColourCIET Source,
ColourGeneric Result
[pure virtual]
 

Implemented in ColourContextRGBT, ColourContextCMYK, ColourContextHSVT, and ColourContextGreyT.

virtual void ColourContext::ConvertToCIET ColourGeneric Source,
DColourCIET Result
[pure virtual]
 

Implemented in ColourContextRGBT, ColourContextCMYK, ColourContextHSVT, and ColourContextGreyT.

void ColourContext::CreateExternalTransform  )  [virtual]
 

Create an external transform to be used during colour conversions from RGB to the current RCS space. This function uses the Winoil CMS Manager to create the transform. Both forward and backward transforms use logical RGB descriptions.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/05/96
Parameters:
- [INPUTS]
Returns:
-

Reimplemented in ColourContextRGBT, ColourContextCMYK, ColourContextHSVT, and ColourContextGreyT.

Definition at line 809 of file colcontx.cpp.

00810 {
00811     // We do nothing here. If no one creates an external transform, the default
00812     // internal one will be used. To create an external transform, call the derived class
00813     // function, not this one as you can see it does nothing.
00814 }

BOOL ColourContext::DecrementUsage void   )  [protected]
 

Decrements usage-count for a colour context. This count allows us to determine when we can delete unused contexts.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/03/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if the object is still in use
Notes: The usage count for a colour context defaults to 0 ("not in use"). When using colour contexts, you should always register them with the global ColContextList object (see ColourContextList::AddContext for details)

Returns:
Errors: ENSURE fails if the usage count goes negative, indicating the context is being 'released' more times than it is 'claimed'.
See also:
ColourContext::IncrementUsage; ColourContextList::AddContext

Definition at line 329 of file colcontx.cpp.

00330 {
00331     ENSURE(UsageCount > 0, "ColourContext::DecrementUsage - Usage count is negative!");
00332     return((--UsageCount) != 0);
00333 }

static void ColourContext::DeinitColourContexts void   )  [static]
 

ColourPlate * ColourContext::DetachColourPlate void   ) 
 

Detaches the ColourPlate (if any) currently attached to this ColourContext. The context will no longer use the colour plate descriptor, and will return to default colour separation/correction actions.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/6/96
Returns:
The pointer to the previously attached ColourPlate (may be NULL)
The caller is now responsible for deleting the returned object **

Notes: The Context's cache handle will be changed so that all cached colours in this output context are effectively 'flushed'.

See also:
ColourPlate; ColourContext::GetColourPlate; ColourContext::SetColourPlate

Definition at line 981 of file colcontx.cpp.

00982 {
00983     ColourPlate *OldColourPlate = ColPlate;
00984 
00985     if (ColPlate != NULL)
00986     {
00987         ColPlate = NULL;
00988 
00989         // Change our context handle so that all cached colours in this context
00990         // are effectively "flushed"
00991         ColourPlateHasChanged();
00992     }
00993 
00994     return(OldColourPlate);
00995 }

ColourModel ColourContext::GetColourModel void   )  const [inline]
 

Determines the colour model on which this colour context is based.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/03/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The colour model on which this colour context is based

Errors: -

See also:
-

Definition at line 367 of file colcontx.h.

00368 {
00369     return(ColModel);
00370 }

ColourPlate * ColourContext::GetColourPlate void   ) 
 

Reads the colour separation/plate for this context.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/01/96
Returns:
NULL if Colour separation is disabled on this context, else a pointer to a ColourPlate descriptor object which describes the current colour separation/filtering options.
See also:
ColourPlate; ColourContext::ApplyOutputFilter; ColourContext::SetColourPlate

Definition at line 1016 of file colcontx.cpp.

01017 {
01018     return(ColPlate);
01019 }

virtual UINT32 ColourContext::GetComponentCount  )  [pure virtual]
 

Implemented in ColourContextRGBT, ColourContextCMYK, ColourContextHSVT, and ColourContextGreyT.

virtual BOOL ColourContext::GetComponentName INT32  ComponentID,
StringBase Result,
BOOL  LongName = FALSE
[pure virtual]
 

Implemented in ColourContextRGBT, ColourContextCMYK, ColourContextHSVT, and ColourContextGreyT.

UnitGroup * ColourContext::GetComponentUnitGroup UINT32  ComponentID  )  [virtual]
 

Provides the UnitGroup of the given component in the ColourModel.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
02/05/96
Parameters:
ComponentID - the number of the component (1..GetComponentCount()) [INPUTS]
- [OUTPUTS]
Returns:
A pointer to the desired UnitGroup

Errors: ERROR2IF ComponentIndex < 1 or greater than number of components in model See Also: ColourContextCMYK::GetComponentUnitGroups() ColourContextGreyT::GetComponentUnitGroups() ColourContextHSVT::GetComponentUnitGroups() ColourContextRGBT::GetComponentUnitGroups()

Definition at line 1111 of file colcontx.cpp.

01112 {
01113     ERROR2IF(ComponentID < 1 || ComponentID > GetComponentCount(), FALSE, "Invalid ID");
01114     UnitGroup** pUnitGroupArray = GetComponentUnitGroups();
01115     ERROR3IF(!(pUnitGroupArray[ComponentID - 1]->IS_KIND_OF(UnitGroup)), 
01116                 "ColourContext::GetComponentUnitGroup - Not UnitGroup array");
01117 
01118     return pUnitGroupArray[ComponentID - 1];
01119 }

virtual UnitGroup** ColourContext::GetComponentUnitGroups  )  [protected, pure virtual]
 

Implemented in ColourContextRGBT, ColourContextCMYK, ColourContextHSVT, and ColourContextGreyT.

ColourContextRGBT * ColourContext::GetCurrentForScreen void   )  [inline, static]
 

Code used by all renderers to find the current screen output context.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/04/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
A pointer to the current screen output colour context for the given colour model. (This will either be the Selected Document's RGBT output context, or the global default output context, if Selected Document returns NULL)
Notes: If you're colour separating, then you should use the context for your current render View - this function just gives a logical global default.

Definition at line 393 of file colcontx.h.

00394 {
00395     Document *Scope = Document::GetSelected();
00396 
00397     if (Scope == NULL)
00398         return((ColourContextRGBT *) GlobalDefaultContext.Context[COLOURMODEL_RGBT]);
00399     else
00400         return((ColourContextRGBT *)
00401                     Scope->GetDefaultColourContexts()->Context[COLOURMODEL_RGBT]);
00402 }

ColourContext * ColourContext::GetGlobalDefault ColourModel  ColModel  )  [inline, static]
 

Find a default colour context for a given colour model number within GLOBAL scope. This is a static function, so may be called without having to create an actual ColourContext instance.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/04/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
A pointer to the default colour context for the given colour model, within the GLOBAL scope.

Errors: -

See also:
ColourContext::GetDefault

Definition at line 424 of file colcontx.h.

00425 {
00426 #ifdef DISABLE_WEBRGBT
00427     if (ColModel==COLOURMODEL_WEBRGBT)
00428         ColModel = COLOURMODEL_RGBT;
00429 #endif
00430     ENSURE(ColModel >= 0 && ColModel < MAX_COLOURMODELS,
00431             "ColourContext::GetGlobalDefault - Illegal colour model!");
00432 
00433     ENSURE(GlobalDefaultContext.Context[ColModel] != NULL,
00434             "Requested global default Colour Context is NULL!");
00435 
00436     return(GlobalDefaultContext.Context[ColModel]);
00437 }

void ColourContext::GetGlobalDefaults ColourContextArray Destination  )  [inline, static]
 

Find the default contexts used by this Scope: Pretty private. Should only need to be used by document.cpp.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/04/94
Parameters:
- [INPUTS]
The supplied destination ColourContextArray will be filled with [OUTPUTS] a copy of the global array of default colour context pointers
Returns:
-

Errors: -

See also:
-

Definition at line 458 of file colcontx.h.

00459 {
00460     memcpy(Destination, &GlobalDefaultContext, sizeof(ColourContextArray));
00461 }

virtual void ColourContext::GetModelName StringBase Result  )  [pure virtual]
 

Implemented in ColourContextRGBT, ColourContextWebRGBT, ColourContextCMYK, ColourContextHSVT, and ColourContextGreyT.

virtual BOOL ColourContext::GetProfileTables BYTE *  Tables  )  [inline, virtual]
 

Reimplemented in ColourContextCMYK.

Definition at line 244 of file colcontx.h.

00244 { return FALSE; }

virtual void ColourContext::GetWhite ColourGeneric Result  )  [pure virtual]
 

Implemented in ColourContextRGBT, ColourContextCMYK, ColourContextHSVT, and ColourContextGreyT.

void ColourContext::IncrementUsage void   )  [inline, protected]
 

Increments usage-count for a colour context. This count allows us to determine when we can delete unused contexts.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/03/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-
Notes: The usage count for a colour context defaults to 0 ("not in use"). When using colour contexts, you should always register them with the global ColContextList object (see ColourContextList::AddContext for details)

Returns:
Errors: -
See also:
ColourContext::DecrementUsage; ColourContextList::AddContext

Definition at line 345 of file colcontx.h.

00346 {
00347     UsageCount++;
00348 }

BOOL ColourContext::Init void   )  [protected, virtual]
 

Colour context initialiser. This is called by the ColourContextList when it wishes to add a context to the list, and makes the context ready for use. This allows the list to compare contexts, and only initialise a given context when it knows the initialisation is absolutely necessary (e.g. allocating a large chunk of memory or calculating a complex table is avoided until we are sure there are no equivalent contexts already available) This function is overridden by colour contexts which actually need to do some initialisation other than just storing a few values away.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/04/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if it succeeds FALSE if it fails (and it'll set an error description)

Errors: -

See also:
ColourContextList::AddContext

Reimplemented from SimpleCCObject.

Definition at line 296 of file colcontx.cpp.

00297 {
00298     ENSURE(UsageCount == 0, "ColourContext initialised when in use?!?!");
00299 
00300     IncrementUsage();   // We are now in use. UsageCount is now 1
00301     return(TRUE);       // Initialisation succeeded
00302 }

static BOOL ColourContext::InitColourContexts void   )  [static]
 

virtual BOOL ColourContext::IsDeviceContext  )  const [inline, virtual]
 

Definition at line 249 of file colcontx.h.

00249 { return CMSTransform != NULL; }

BOOL ColourContext::IsDifferent ColourContext Other  )  const [virtual]
 

Determine if two colour contexts are not exactly equivalent.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/04/94
Parameters:
Other - a colour context to compare ourselves to [INPUTS]
- [OUTPUTS]
Returns:
TRUE if the other colour context object is different from ourself, or FALSE if it is an exactly equivalent context.

Errors: -

See also:
-

Reimplemented in ColourContextRGBT, and ColourContextCMYK.

Definition at line 434 of file colcontx.cpp.

00435 {
00436     if (Other == this)
00437         return(FALSE);                      // Different object? (Nope)
00438 
00439     if (Other->ScopeView != ScopeView)
00440         return(TRUE);                       // Different Scope Views?
00441 
00442     return(Other->ColModel != ColModel);    // Different Colour Model?
00443 }

void ColourContext::PackColour ColourGeneric Source,
ColourPacked Result
[protected, virtual]
 

Converts 128-bit colour representation to 32-bit packed form.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/03/94
Parameters:
Source - A ColourGeneric structure defining the colour in the model [INPUTS] pertaining to this colour context. Result - A Packed colour structure in the same model, into which the result is copied.
- [OUTPUTS]
Returns:
-
Notes: This function operates on the colour using a generic component pattern Colours such as ColourHSVT do not conform to this pattern and thus must be unpacked with derived methods (ColourContextHSVT::UnpackColour) However, this function will work on any 4-component model which uses 8bits and 32-bits respectively for all 4 components, and the same 8.24 fixedpoint 32-bit representation.

Scope: Private (used internally by friend class DocColour)

Returns:
Errors: -
See also:
ColourContext::UnpackColour

Reimplemented in ColourContextHSVT.

Definition at line 365 of file colcontx.cpp.

00366 {
00367     PColourGeneric *bob = (PColourGeneric *) Result;
00368 
00369     bob->Component1 = PackColour256(Source->Component1);
00370     bob->Component2 = PackColour256(Source->Component2);
00371     bob->Component3 = PackColour256(Source->Component3);
00372     bob->Component4 = PackColour256(Source->Component4);
00373 }

PColourValue ColourContext::PackColour128 ColourValue  Source  )  [inline, protected]
 

Given a 32-bit (FIXED24) colour definition value, packs it into a 7-bit (unsigned byte) colour definition value. The value is rounded and clipped to lie within gamut (0.0 <= g <= 1.0).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/04/94
Parameters:
Source - The source FIXED24 value to be packed into an 8-bit value [INPUTS]
Returns:
A packed representation of the input value
Scope: private - used internally by ColourContext code
See also:
ColourContext::UnpackColour128

Definition at line 510 of file colcontx.h.

00511 {
00512     // Get the value as a fixed24 INT32, and round it up by half a 0..127 value
00513     INT32 result = Source.GetAsFixed24() + 0x00010000;
00514 
00515     // Clip the value into the FIXED24 range 0.0 - 1.0
00516     if (result > 0x01000000)
00517         result = 0x01000000;
00518 
00519     if (result < 0)
00520         result = 0;
00521 
00522     // Multiply by 127, and shift the resulting value down to get a 7-bit value
00523     result = (result * 127) >> 24;
00524 
00525     return((PColourValue) result);
00526 }

PColourValue ColourContext::PackColour256 ColourValue  Source  )  [inline, protected]
 

Given a 32-bit (FIXED24) colour definition value, packs it into an 8-bit (unsigned byte) colour definition value. The value is rounded and clipped to lie within gamut (0.0 <= g <= 1.0).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/04/94
Parameters:
Source - The source FIXED24 value to be packed into an 8-bit value [INPUTS]
Returns:
A packed representation of the input value
Scope: private - used internally by ColourContext code
See also:
ColourContext::UnpackColour256

Definition at line 586 of file colcontx.h.

00587 {
00588     // Get the value as a fixed24 INT32, and round it up by half a 0..255 value
00589     INT32 result = Source.GetAsFixed24() + 0x00008000;
00590 
00591     // Clip the value into the FIXED24 range 0.0 - 1.0
00592     if (result > 0x01000000)
00593         result = 0x01000000;
00594 
00595     if (result < 0)
00596         result = 0;
00597 
00598     // Multiply by 255, and shift the resulting value down to get a byte value
00599     result = (result * 255) >> 24;
00600 
00601     return((PColourValue) result);
00602 }

PColourValue ColourContext::PackColour360 ColourValue  Source  )  [inline, protected]
 

Given a 32-bit (FIXED24) colour definition value, packs it into a 9-bit (0..359) colour definition value. The value is rounded and clipped to lie within gamut (0.0 <= g <= 1.0).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/04/94
Parameters:
Source - The source FIXED24 value to be packed into a 9-bit value [INPUTS]
Returns:
A packed representation of the input value
Scope: private - used internally by ColourContext code
See also:
ColourContext::UnpackColour360

Definition at line 658 of file colcontx.h.

00659 {
00660 /*
00661     // Get the value as a fixed24 INT32, and round it up by half a 0..360 value
00662     INT32 result = Source.GetAsFixed24() + 0x00005606;
00663 
00664     // Clip the value into the FIXED24 range 0.0 - 1.0
00665     if (result > 0x01000000)
00666         result = 0x01000000;
00667 
00668     if (result < 0)
00669         result = 0;
00670 
00671     // Convert to 9.23 bit fixed point, to avoid overflow in the multiply below
00672     result >>= 1;
00673 
00674     // Multiply by 255, and shift the resulting value down to get a byte value
00675     result = (result * 359) >> 23;
00676 */
00677 
00678     // Doubles are more accurate, simpler, and quite possibly faster than the code above
00679     double result = (Source.MakeDouble() * 359.0) + 0.5;
00680 
00681     if (result > 359.0)
00682         result = 359.0;
00683 
00684     if (result < 0.0)
00685         result = 0.0;
00686 
00687     return((PColourValue) result);
00688 }

void ColourContext::SetColourPlate ColourPlate NewColourPlate  ) 
 

Sets a colour separation/plate for this context.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/01/96
Parameters:
NULL (to disable colour seps), or points to the new ColourPlate descriptor object [INPUTS] NOTE that the ColourPlate object now belongs to the ColourContext, and will be deleted by the context when it is finished with it.
Notes: The ColourPlate object now belongs to the ColourContext, and will be deleted by the context when it is finished with it.

(To remove the ColourPlate again in a way that does not delete the ColourPlate, call ColourContext::DetachColourPlate rather than SetColourPlate(NULL))

The Context's cache handle will be changed so that all cached colours in this output context are effectively 'flushed'.

See also:
ColourPlate; ColourContext::ApplyOutputFilter; ColourContext::GetColourPlate; ColourContext::DetachColourPlate

Definition at line 936 of file colcontx.cpp.

00937 {
00938     // Trying to set ColourPlate to the one we're already using - ignore them!
00939     if (ColPlate == NewColourPlate)
00940         return;
00941 
00942     // Delete our current ColourPlate
00943     if (ColPlate != NULL)
00944     {
00945         delete ColPlate;
00946         ColPlate = NULL;
00947     }
00948 
00949     // Remember our new ColourPlate filter descriptor
00950     ColPlate = NewColourPlate;
00951 
00952     // Change our context handle so that all cached colours in this context
00953     // are effectively "flushed"
00954     ColourPlateHasChanged();
00955 }

BOOL ColourContext::SetComponentUnitGroup UINT32  ComponentID,
UnitGroup pComponentUnitGroup
[virtual]
 

Definition at line 1076 of file colcontx.cpp.

01077 {
01078     ERROR2IF(ComponentID < 1 || ComponentID > GetComponentCount(), FALSE, "Invalid Index");
01079     ERROR2IF(pComponentUnitGroup == NULL, FALSE, "Invalid UnitGroup");
01080 
01081     ERROR3IF(!pComponentUnitGroup->IS_KIND_OF(UnitGroup), "Invalid UnitGroup");
01082 
01083     UnitGroup** pUnitGroupArray = GetComponentUnitGroups();
01084     ERROR3IF(!(pUnitGroupArray[ComponentID - 1]->IS_KIND_OF(UnitGroup)), 
01085                 "ColourContext::GetComponentUnitGroup - Not UnitGroup array");
01086 
01087     pUnitGroupArray[ComponentID - 1] = pComponentUnitGroup;
01088     return TRUE;
01089 }

void ColourContext::SetGlobalDefault ColourModel  ColModel,
ColourContext Default
[inline, static, protected]
 

Set the default colour context for a given colour model number Scope: private - used internally by ColourContextList::InitColourContexts.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/04/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 481 of file colcontx.h.

00482 {
00483 #ifdef DISABLE_WEBRGBT
00484     if (ColModel==COLOURMODEL_WEBRGBT)
00485         ColModel = COLOURMODEL_RGBT;
00486 #endif
00487     GlobalDefaultContext.Context[ColModel] = Default;
00488 }

void ColourContext::UnpackColour ColourPacked Source,
ColourGeneric Result
[protected, virtual]
 

Converts 32-bit packed colour representation to 128-bit form.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/03/94
Parameters:
Source - A Packed Colour structure defining the colour in the model [INPUTS] pertaining to this colour context. Result - A ColourGeneric structure in the same model, into which the result is copied.
- [OUTPUTS]
Returns:
-
Notes: This function operates on the colour using a generic component pattern Colours such as ColourHSVT do not conform to this pattern and thus must be unpacked with derived methods (ColourContextHSVT::UnpackColour) However, this function will work on any 4-component model which uses 8bits and 32-bits respectively for all 4 components, and the same 8.24 fixedpoint 32-bit representation.

Scope: Private (used internally by friend class DocColour)

Returns:
Errors: -
See also:
ColourContext::PackColour

Reimplemented in ColourContextHSVT.

Definition at line 405 of file colcontx.cpp.

00406 {
00407     PColourGeneric *bob = (PColourGeneric *) Source;
00408 
00409     UnpackColour256(bob->Component1, &Result->Component1);
00410     UnpackColour256(bob->Component2, &Result->Component2);
00411     UnpackColour256(bob->Component3, &Result->Component3);
00412     UnpackColour256(bob->Component4, &Result->Component4);
00413 }

void ColourContext::UnpackColour128 PColourValue  Source,
FIXED24 Result
[inline, protected]
 

Unpacks the packed source colour value into a FIXED24 unpacked format.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/04/94
Parameters:
Source - The packed input value, as a 7-bit (0..127) value. [INPUTS]
Result - is filled in on exit with an unpacked (FIXED24) version of the [OUTPUTS] source 7-bit value
Scope: private - used internally by ColourContext code
See also:
ColourContext::PackColour128

Definition at line 547 of file colcontx.h.

00548 {
00549     INT32 temp = (INT32) Source;
00550 
00551     if (temp >= 127)        // If hit upper limit of gamut, return 1.0
00552         *Result = 1.0;
00553     else
00554     {
00555         if (temp <= 0)      // if hit lower limit of gamut, return 0.0
00556             *Result = 0;
00557         else
00558         {
00559             // Repeat the 7 bit value 4 times in the bottom 24 bits of the word
00560             // (losing the LS 4 bits of the LS copy off the end, hence ">>4")
00561             Result->SetAsFixed24((temp >> 4) | (temp << 3) | (temp << 10) | (temp << 17));
00562         }
00563     }
00564 }

void ColourContext::UnpackColour256 PColourValue  Source,
FIXED24 Result
[inline, protected]
 

Unpacks the packed source colour value into a FIXED24 unpacked format.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/04/94
Parameters:
Source - The packed input value, as a 8-bit (0..255) value. [INPUTS]
Result - is filled in on exit with an unpacked (FIXED24) version of the [OUTPUTS] source 8-bit value
Scope: private - used internally by ColourContext code
See also:
ColourContext::PackColour256

Definition at line 623 of file colcontx.h.

00624 {
00625     INT32 temp = (INT32) Source;
00626 
00627     if (temp >= 255)        // If hit upper limit of gamut, return 1.0
00628         *Result = 1.0;
00629     else
00630     {
00631         if (temp <= 0)      // If hit lower limit of gamut, return 0.0
00632             *Result = 0;
00633         else
00634             Result->SetAsFixed24(temp | (temp << 8) | (temp << 16));
00635     }
00636 }

void ColourContext::UnpackColour360 PColourValue  Source,
FIXED24 Result
[inline, protected]
 

Unpacks the packed source colour value into a FIXED24 unpacked format.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/04/94
Parameters:
Source - The packed input value, as a 9-bit (0..359) value. [INPUTS]
Result - is filled in on exit with an unpacked (FIXED24) version of the [OUTPUTS] source 9-bit value
Scope: private - used internally by ColourContext code
See also:
ColourContext::PackColour360

Definition at line 709 of file colcontx.h.

00710 {
00711 /*
00712     INT32 temp = (INT32) Source;
00713 
00714     if (temp > 359) temp = 359;
00715     if (temp < 0)   temp = 0;
00716 
00717     // The number fits into 9 bits, so shift it up to get 9.23 bit fixed point
00718     // then divide by 359 to scale it, then  shift it up by one more bit
00719     // to convert into 8.24 fixed point (thus we lose the 24th bit of accuracy)
00720 
00721     temp = (temp << 23) / 359;          // Get scaled value as 9.23 bit fp
00722 
00723     Result->SetAsFixed24(temp << 1);    // Convert to 8.24 fp and then to FIXED24
00724 */
00725 
00726     // Doubles are more accurate, simpler, and quite possibly faster than the code above
00727     double temp = Source;
00728 
00729     temp /= 359.0;
00730 
00731     if (temp < 0.0)
00732         temp = 0.0;
00733 
00734     if (temp > 1.0)
00735         temp = 1.0;
00736 
00737     *Result = temp;
00738 }


Friends And Related Function Documentation

friend class ColourContextList [friend]
 

Reimplemented in ColourContextRGBT, ColourContextCMYK, ColourContextHSVT, and ColourContextGreyT.

Definition at line 176 of file colcontx.h.

friend class DocColour [friend]
 

Reimplemented in ColourContextRGBT, ColourContextCMYK, ColourContextHSVT, and ColourContextGreyT.

Definition at line 175 of file colcontx.h.

friend class GRenderRegion [friend]
 

Reimplemented in ColourContextRGBT, ColourContextCMYK, ColourContextHSVT, and ColourContextGreyT.

Definition at line 178 of file colcontx.h.

friend class OSRenderRegion [friend]
 

Reimplemented in ColourContextRGBT, ColourContextCMYK, ColourContextHSVT, and ColourContextGreyT.

Definition at line 179 of file colcontx.h.


Member Data Documentation

HCMTRANSFORM ColourContext::CMSTransform [protected]
 

Definition at line 262 of file colcontx.h.

ColourModel ColourContext::ColModel [protected]
 

Definition at line 256 of file colcontx.h.

ColourPlate* ColourContext::ColPlate [protected]
 

Definition at line 258 of file colcontx.h.

ColourContextArray ColourContext::GlobalDefaultContext [static, private]
 

Initial value:

 
{
    { NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL,
    NULL, NULL, NULL, NULL }
}

Definition at line 313 of file colcontx.h.

ColourContextHandle ColourContext::MyHandle [protected]
 

Definition at line 253 of file colcontx.h.

ColourContextHandle ColourContext::NextColourContextHandle = 1 [static, protected]
 

Definition at line 269 of file colcontx.h.

View* ColourContext::ScopeView [protected]
 

Definition at line 265 of file colcontx.h.

INT32 ColourContext::UsageCount [protected]
 

Definition at line 254 of file colcontx.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:52:47 2007 for Camelot by  doxygen 1.4.4