#include <colcontx.h>
Inheritance diagram for ColourContext:
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 UnitGroup * | GetComponentUnitGroup (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. | |
ColourPlate * | GetColourPlate (void) |
Reads the colour separation/plate for this context. | |
ColourPlate * | 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. | |
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 ColourContext * | GetGlobalDefault (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 ColourContextRGBT * | GetCurrentForScreen (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 |
ColourPlate * | ColPlate |
HCMTRANSFORM | CMSTransform |
View * | ScopeView |
Static Protected Attributes | |
static ColourContextHandle | NextColourContextHandle = 1 |
Static Private Attributes | |
static ColourContextArray | GlobalDefaultContext |
Friends | |
class | DocColour |
class | ColourContextList |
class | GRenderRegion |
class | OSRenderRegion |
Definition at line 173 of file colcontx.h.
|
Constructor for a Colour context. This is shared code used by all derived ColourContextXXXX classes. You cannot create vanilla ColourContext objects (virtual functions abound).
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.
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 }
|
|
Colour context destructor.
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 }
|
|
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.
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.
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 }
|
|
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.
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.
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 }
|
|
Implemented in ColourContextRGBT, ColourContextCMYK, ColourContextHSVT, and ColourContextGreyT. |
|
Implemented in ColourContextRGBT, ColourContextCMYK, ColourContextHSVT, and ColourContextGreyT. |
|
Effectively flushes the caches of all colours currently cached in this ColourContext, so that on the next redraw they will re-convert.
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
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 }
|
|
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.
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 }
|
|
Converts a colour in any arbitrary colour context into this colour context. The converted colour will be supplied from a cache where possible.
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 }
|
|
Converts an indexed colour into this colour context. The converted colour will be supplied from a cache where possible.
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 }
|
|
Converts a Colour into this colour context. The converted colour will be supplied from a cache where possible.
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 }
|
|
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.
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.
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
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 }
|
|
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.
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 }
|
|
Converts a Colour into this colour context. The converted colour will be supplied from a cache where possible.
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 }
|
|
Implemented in ColourContextRGBT, ColourContextCMYK, ColourContextHSVT, and ColourContextGreyT. |
|
Implemented in ColourContextRGBT, ColourContextCMYK, ColourContextHSVT, and ColourContextGreyT. |
|
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.
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 }
|
|
Decrements usage-count for a colour context. This count allows us to determine when we can delete unused contexts.
Definition at line 329 of file colcontx.cpp. 00330 { 00331 ENSURE(UsageCount > 0, "ColourContext::DecrementUsage - Usage count is negative!"); 00332 return((--UsageCount) != 0); 00333 }
|
|
|
|
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.
Notes: The Context's cache handle will be changed so that all cached colours in this output context are effectively 'flushed'.
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 }
|
|
Determines the colour model on which this colour context is based.
Definition at line 367 of file colcontx.h. 00368 { 00369 return(ColModel); 00370 }
|
|
Reads the colour separation/plate for this context.
Definition at line 1016 of file colcontx.cpp. 01017 { 01018 return(ColPlate); 01019 }
|
|
Implemented in ColourContextRGBT, ColourContextCMYK, ColourContextHSVT, and ColourContextGreyT. |
|
Implemented in ColourContextRGBT, ColourContextCMYK, ColourContextHSVT, and ColourContextGreyT. |
|
Provides the UnitGroup of the given component in the ColourModel.
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 }
|
|
Implemented in ColourContextRGBT, ColourContextCMYK, ColourContextHSVT, and ColourContextGreyT. |
|
Code used by all renderers to find the current screen output context.
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 }
|
|
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.
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 }
|
|
Find the default contexts used by this Scope: Pretty private. Should only need to be used by document.cpp.
Definition at line 458 of file colcontx.h. 00459 { 00460 memcpy(Destination, &GlobalDefaultContext, sizeof(ColourContextArray)); 00461 }
|
|
Implemented in ColourContextRGBT, ColourContextWebRGBT, ColourContextCMYK, ColourContextHSVT, and ColourContextGreyT. |
|
Reimplemented in ColourContextCMYK. Definition at line 244 of file colcontx.h. 00244 { return FALSE; }
|
|
Implemented in ColourContextRGBT, ColourContextCMYK, ColourContextHSVT, and ColourContextGreyT. |
|
Increments usage-count for a colour context. This count allows us to determine when we can delete unused contexts.
Definition at line 345 of file colcontx.h. 00346 { 00347 UsageCount++; 00348 }
|
|
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.
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 }
|
|
|
|
Definition at line 249 of file colcontx.h. 00249 { return CMSTransform != NULL; }
|
|
Determine if two colour contexts are not exactly equivalent.
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 }
|
|
Converts 128-bit colour representation to 32-bit packed form.
Scope: Private (used internally by friend class DocColour)
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 }
|
|
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).
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 }
|
|
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).
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 }
|
|
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).
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 }
|
|
Sets a colour separation/plate for this context.
(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'.
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 }
|
|
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 }
|
|
Set the default colour context for a given colour model number Scope: private - used internally by ColourContextList::InitColourContexts.
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 }
|
|
Converts 32-bit packed colour representation to 128-bit form.
Scope: Private (used internally by friend class DocColour)
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 }
|
|
Unpacks the packed source colour value into a FIXED24 unpacked format.
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 }
|
|
Unpacks the packed source colour value into a FIXED24 unpacked format.
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 }
|
|
Unpacks the packed source colour value into a FIXED24 unpacked format.
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 }
|
|
Reimplemented in ColourContextRGBT, ColourContextCMYK, ColourContextHSVT, and ColourContextGreyT. Definition at line 176 of file colcontx.h. |
|
Reimplemented in ColourContextRGBT, ColourContextCMYK, ColourContextHSVT, and ColourContextGreyT. Definition at line 175 of file colcontx.h. |
|
Reimplemented in ColourContextRGBT, ColourContextCMYK, ColourContextHSVT, and ColourContextGreyT. Definition at line 178 of file colcontx.h. |
|
Reimplemented in ColourContextRGBT, ColourContextCMYK, ColourContextHSVT, and ColourContextGreyT. Definition at line 179 of file colcontx.h. |
|
Definition at line 262 of file colcontx.h. |
|
Definition at line 256 of file colcontx.h. |
|
Definition at line 258 of file colcontx.h. |
|
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. |
|
Definition at line 253 of file colcontx.h. |
|
Definition at line 269 of file colcontx.h. |
|
Definition at line 265 of file colcontx.h. |
|
Definition at line 254 of file colcontx.h. |