#include <doccolor.h>
Public Member Functions | |
| DocColour () | |
| Constructor for a DocColour Initialises the colour to an RGBT value representing 'no colour'. (i.e. The same as DocColour(COLOUR_TRANS)). | |
| ~DocColour () | |
| Destructor for a DocColour. | |
| DocColour (StockColour Col) | |
| Constructor for a DocColour Initialises it to the given predefined (stock) colours, as defined in stockcol.h (cf keyword StockColour). | |
| DocColour (ColourModel ColModel, ColourGeneric *Col) | |
| Constructor for a DocColour Initialises it to the given value. | |
| DocColour (ColourValue Red, ColourValue Green, ColourValue Blue) | |
| Constructor for a DocColour Initialises it to the given RGBT value. Values are ColourValues (FIXED24s) in the range 0.0 to 1.0. | |
| DocColour (const DocColour &other) | |
| DocColour copy constructor Notes: If copying a reference to an indexed colour, the indexed colours usage count will be incremented. If this is already a reference to an indexed colour, that indexed colours usage count will be decremented. | |
| DocColour & | operator= (const DocColour &) |
| DocColour assignment operator Notes: If copying a reference to an indexed colour, the indexed colours usage count will be incremented. If this is already a reference to an indexed colour, that indexed colours usage count will be decremented. | |
| void | MakeRefToIndexedColour (IndexedColour *Other) |
| IndexedColour * | FindParentIndexedColour (void) |
| Determines if a colour references an IndexedColour, and if so, gives access to the parent colour. | |
| void | MakeRefToIndexedColourDBG (IndexedColour *Other, LPCSTR TheFile=NULL, INT32 TheLine=0) |
| DocColour assignment - Makes this DocColour a reference to the given Indexed Colour. The Indexed Colour cannot be deleted until this DocColour releases this claim upon it (which occurs when it is deleted or re-assigned). | |
| IndexedColour * | GetSpotParent (void) |
| To determine which spot colour (if any) is the ultimate spot colour parent of this DocColour. (i.e. to see which spot plate a DocColour will appear on). | |
| BOOL | operator== (const DocColour) const |
| DocColour comparison operator. | |
| BOOL | operator!= (const DocColour) const |
| DocColour comparison operator Notes: If comparing two references to indexed colours, they will only be considered equal if they reference the SAME indexed colour (i.e. we do not compare the indexed colours). | |
| ColourModel | GetColourModel (void) const |
| {Copy} Constructor for a DocColour Notes: THIS FUNCTION DOES NOT EXIST!! DocColour::MakeRefToIndexedColour() should be used if you wish to "assign" an IndexedColour to a DocColour. To determine the colourmodel in which the given colour was defined Notes: If this is a reference to an IndexedColour, returns the colour of the referenced IndexedColour. The colour model number returned may be used as an index into the list of ColourContexts held by each document, in order to find a relevant context for the colour. | |
| void | GetSourceColour (ColourGeneric *Result) |
| Determine the native definition of the given colour Notes: If this is a reference to an IndexedColour, returns the colour of the referenced IndexedColour. | |
| BOOL | IsTransparent (void) const |
| Determines if a colour's "no colour" flag is set. | |
| BOOL | IsSeparable (void) const |
| Determines if a colour's "IsSeparable" flag is set. | |
| void | SetSeparable (BOOL IsSeparable=TRUE) |
| To set the separation/correction enable flag for a DocColour. Some colours (e.g. EOR blob colours) should not be colour-separated on screen. By default, all colours (except StockCols) will separate, but this flag can be set on "UI colours" to stop them separating. | |
| void | Mix (DocColour *BlendStart, DocColour *BlendEnd, double BlendFraction, ColourContext *BlendContext, BOOL BlendTheLongWay=FALSE, ColourContext *OutputContext=NULL) |
| "Constructor" for a DocColour - generates a blended DocColour The start and end colours are blended to create this new DocColour. The amount by which they are mixed is determined by BlendFraction. The blend occurs in the colourspace described by BlendContext. Note that BlendContext may be NULL, in which case the default context for the BlendStart colour will be used. However, this is not recommended, as this will result in a blend which may be incorrect for the context(s) in use in a given document, which could give seriously wonky colours! | |
| void | ForceRounding (BOOL RoundingOn) |
| BOOL | IsForcedToRound (void) |
| void | SetReservedFlag (UINT32 Value) |
| To set the Reserved flag of the colour info struct. | |
| UINT32 | GetReservedFlag () |
| access fn. | |
| BOOL | IsNamed () |
| to identidy if this colour is named, or was created from a named colour. Note that not all colours that were created by Named colours will have the relevant flag set, as I have only just started using it (4/2000). This fn. was really designed to be used specifically by the brush attribute replace named colours system. | |
| void | HackColReplacerPreDestruct () |
| As you might expect from the name this is a real bodge. Basically the named colour replacer used in the brush needs to store some colours which are converted index colours. To cut a long story short I'm looking at a deadline and this prevents an assert upon destruction, theres no reason for anyone else to use it. | |
| void | GetDebugDetails (StringBase *Str) |
| void | SetRGBValue (INT32 Red, INT32 Green, INT32 Blue) |
| void | GetRGBValue (INT32 *Red, INT32 *Green, INT32 *Blue) |
| void | SetCMYKValue (PColourCMYK *New) |
| void | GetCMYKValue (PColourCMYK *Result) |
| void | GetCMYKValue (ColourContext *pContext, PColourCMYK *Result) |
| void | SetHSVValue (INT32 h, INT32 s, INT32 v) |
| void | GetHSVValue (INT32 *h, INT32 *s, INT32 *v) |
| DocColour (INT32 Red, INT32 Green, INT32 Blue) | |
Protected Member Functions | |
| void | MixRGB (DocColour *BlendStart, DocColour *BlendEnd, double BlendFraction, ColourContext *BlendContext) |
| Internal helper function for DocColour::Mix. This is a reasonably optimised routine for mixing RGB colours. | |
| void | MixCMYK (DocColour *BlendStart, DocColour *BlendEnd, double BlendFraction, ColourContext *BlendContext) |
| Internal helper function for DocColour::Mix. This is a reasonably optimised routine for mixing CMYK colours. | |
| void | MixHSV (DocColour *BlendStart, DocColour *BlendEnd, double BlendFraction, ColourContext *BlendContext, BOOL BlendTheLongWay=FALSE) |
| Internal helper function for DocColour::Mix. This is a reasonably optimised routine for mixing HSV colours. | |
| void | MixTint (IndexedColour *SpotParent, IndexedColour *StartTint, IndexedColour *EndTint, double BlendFraction) |
| Internal helper function for DocColour::Mix. This method is used to mix the DocColours to an IndexedColour result when one or both of the end colours are tints. This simply linearly interpolates the tint values. | |
| void | InitialiseInfoField (ColourModel ColModel) |
| Private shared code for construction of DocColour objects Initialises the 'Info' structure to default values Scope: private. | |
| void | ZapSourceColour () |
Protected Attributes | |
| ColourInfo | Info |
| ColourPacked | SourceColour |
| ColourPacked | CachedColour |
Friends | |
| class | ColourContext |
DocColours can be defined in any of the available colour models.
DocColours are stored to "low" (32-bit) precision, except when they are references to IndexedColours (which are 128-bit precision). However, colour calculations, and access to values stored in colours are generally only available through the 128bit interface.
Notes: NOTE that any use of a DocColour may result in updating its cache, so you must NOT treat DocColours as const anywhere. Also, work on original DocColours rather than copies if you want the cache to be kept fresh on the original.
Definition at line 179 of file doccolor.h.
|
|
Constructor for a DocColour Initialises the colour to an RGBT value representing 'no colour'. (i.e. The same as DocColour(COLOUR_TRANS)).
Definition at line 185 of file doccolor.cpp. 00186 { 00187 ZapSourceColour(); 00188 InitialiseInfoField(COLOURMODEL_RGBT); 00189 00190 SourceColour.RGBT.Red = 0; // Black & 100% Transparent 00191 SourceColour.RGBT.Green = 0; 00192 SourceColour.RGBT.Blue = 0; 00193 SourceColour.RGBT.Transparent = 255; 00194 00195 Info.NoColour = TRUE; // And also 'no colour' transparent 00196 }
|
|
|
Destructor for a DocColour.
Definition at line 215 of file doccolor.cpp. 00216 { 00217 // If we are a reference to an indexed colour, tell that colour that we are 00218 // no longer referencing it 00219 if (Info.SourceColourModel == COLOURMODEL_INDEXED) 00220 SourceColour.Indexed.Colour->DecrementUsage(); 00221 }
|
|
|
Constructor for a DocColour Initialises it to the given predefined (stock) colours, as defined in stockcol.h (cf keyword StockColour).
Definition at line 250 of file doccolor.cpp. 00251 { 00252 ZapSourceColour(); 00253 PColourValue Red = 0, Green = 0, Blue = 0, Transparent = 0; 00254 00255 InitialiseInfoField(COLOURMODEL_RGBT); 00256 00257 switch (Col) 00258 { 00259 case COLOUR_TRANS: 00260 Red = Green = Blue = Transparent = 255; 00261 Info.NoColour = TRUE; 00262 break; 00263 00264 case COLOUR_BLACK: 00265 case COLOUR_UNSELECTEDBLOB: 00266 case COLOUR_FILLDEFAULT: 00267 case COLOUR_LINEDEFAULT: 00268 case COLOUR_XORDRAG: 00269 break; 00270 00271 case COLOUR_DKGREY: 00272 Red = Green = Blue = 64; 00273 break; 00274 00275 case COLOUR_MIDGREY: 00276 Red = Green = Blue = 128; 00277 break; 00278 00279 case COLOUR_XOREDIT: 00280 Red = 64; 00281 Green = 64; 00282 Blue = 230; 00283 break; 00284 00285 case COLOUR_LTGREY: 00286 case COLOUR_BEZIERLINE: 00287 Red = Green = Blue = 192; 00288 break; 00289 00290 case COLOUR_WHITE: 00291 Red = Green = Blue = 255; 00292 break; 00293 00294 case COLOUR_RED: 00295 case COLOUR_XORSELECT: 00296 case COLOUR_TOOLBLOB: 00297 case COLOUR_SELECTEDBLOB: 00298 case COLOUR_BEZIERBLOB: 00299 Red = 255; 00300 break; 00301 00302 case COLOUR_GREEN: 00303 Green = 255; 00304 break; 00305 00306 case COLOUR_BLUE: 00307 case COLOUR_XORNEW: 00308 case COLOUR_GRID: 00309 Blue = 255; 00310 break; 00311 00312 case COLOUR_CYAN: 00313 Green = Blue = 255; 00314 break; 00315 00316 case COLOUR_MAGENTA: 00317 Red = Blue = 255; 00318 break; 00319 00320 case COLOUR_YELLOW: 00321 Red = Green = 255; 00322 break; 00323 } 00324 00325 00326 SourceColour.RGBT.Red = Red; 00327 SourceColour.RGBT.Green = Green; 00328 SourceColour.RGBT.Blue = Blue; 00329 SourceColour.RGBT.Transparent = Transparent; 00330 00331 Info.IsSeparable = FALSE; 00332 }
|
|
||||||||||||
|
Constructor for a DocColour Initialises it to the given value.
Definition at line 403 of file doccolor.cpp. 00404 { 00405 ZapSourceColour(); 00406 InitialiseInfoField(ColModel); 00407 DEFAULTCONTEXT(ColModel)->PackColour(Col, &SourceColour); 00408 }
|
|
||||||||||||||||
|
Constructor for a DocColour Initialises it to the given RGBT value. Values are ColourValues (FIXED24s) in the range 0.0 to 1.0.
Definition at line 357 of file doccolor.cpp. 00358 { 00359 ZapSourceColour(); 00360 ColourRGBT temp; 00361 00362 InitialiseInfoField( COLOURMODEL_RGBT ); 00363 00364 temp.Red = Red; // Copy data into 128-bit struct, then pack 00365 temp.Green = Green; // it into our 32-bit store. 00366 temp.Blue = Blue; 00367 temp.Transparent = 0; 00368 00369 DEFAULTCONTEXT(COLOURMODEL_RGBT)->PackColour( (ColourGeneric *)&temp, &SourceColour ); 00370 }
|
|
|
DocColour copy constructor Notes: If copying a reference to an indexed colour, the indexed colours usage count will be incremented. If this is already a reference to an indexed colour, that indexed colours usage count will be decremented.
Definition at line 430 of file doccolor.cpp. 00431 { 00432 ENSURE(Other.Info.SourceColourModel < MAX_COLOURMODELS, 00433 "Attempt to use illegal colour model!"); 00434 00435 Info = Other.Info; 00436 CachedColour = Other.CachedColour; 00437 SourceColour = Other.SourceColour; 00438 00439 if (Info.SourceColourModel == COLOURMODEL_INDEXED) 00440 { 00441 ENSURE(SourceColour.Indexed.Colour != NULL, 00442 "Corrupted DocColour (NULL IndexedColour ref) detected"); 00443 00444 SourceColour.Indexed.Colour->IncrementUsage(); 00445 ENSURE(Info.CacheColourModel == 0, "RefToIndexedColour DocColour has a cache!!"); 00446 00447 #ifdef TRACECOLOURIX 00448 TRACE( _T(">> Construct DocColour(DocColour => ColourIx %x) @ %x\n"), (INT32)SourceColour.Indexed.Colour, (INT32)this); 00449 #endif 00450 } 00451 }
|
|
||||||||||||||||
|
Definition at line 1612 of file doccolor.cpp. 01613 { 01614 ZapSourceColour(); 01615 InitialiseInfoField(COLOURMODEL_RGBT); 01616 01617 SourceColour.RGBT.Red = (PColourValue) Red; 01618 SourceColour.RGBT.Green = (PColourValue) Green; 01619 SourceColour.RGBT.Blue = (PColourValue) Blue; 01620 SourceColour.RGBT.Transparent = 0; 01621 }
|
|
|
Determines if a colour references an IndexedColour, and if so, gives access to the parent colour.
Definition at line 413 of file doccolor.h. 00414 { 00415 if (Info.SourceColourModel != COLOURMODEL_INDEXED) 00416 return(NULL); 00417 00418 return(SourceColour.Indexed.Colour); 00419 }
|
|
|
Definition at line 246 of file doccolor.h. 00246 { Info.ForceRounding = RoundingOn; };
|
|
||||||||||||
|
Definition at line 1715 of file doccolor.cpp. 01716 { 01717 if (pContext!=NULL) 01718 { 01719 ERROR3IF(pContext->GetColourModel() != COLOURMODEL_CMYK, "Colour context is not CMYK!"); 01720 pContext->ConvertColour(this, (ColourPacked *) Result); 01721 return; 01722 } 01723 01724 ColourContext *CCcmyk = ColourContext::GetGlobalDefault(COLOURMODEL_CMYK); 01725 ERROR3IF(CCcmyk == NULL, "No default CMYK colour context?!"); 01726 01727 CCcmyk->ConvertColour(this, (ColourPacked *) Result); 01728 }
|
|
|
Definition at line 1708 of file doccolor.cpp. 01709 { 01710 ColourContext *CCcmyk = ColourContext::GetGlobalDefault(COLOURMODEL_CMYK); 01711 CCcmyk->ConvertColour(this, (ColourPacked *) Result); 01712 }
|
|
|
{Copy} Constructor for a DocColour Notes: THIS FUNCTION DOES NOT EXIST!! DocColour::MakeRefToIndexedColour() should be used if you wish to "assign" an IndexedColour to a DocColour. To determine the colourmodel in which the given colour was defined Notes: If this is a reference to an IndexedColour, returns the colour of the referenced IndexedColour. The colour model number returned may be used as an index into the list of ColourContexts held by each document, in order to find a relevant context for the colour.
Definition at line 490 of file doccolor.cpp. 00491 { 00492 ENSURE(Info.SourceColourModel < MAX_COLOURMODELS, 00493 "DocColour based on illegal colour model!"); 00494 00495 // If colour is a reference to an indexed colour, return indexed colour's 00496 // colour model 00497 if (Info.SourceColourModel == COLOURMODEL_INDEXED) 00498 { 00499 ENSURE(SourceColour.Indexed.Colour != NULL, 00500 "Corrupted DocColour (NULL IndexedColour ref) detected"); 00501 return(SourceColour.Indexed.Colour->GetColourModel()); 00502 } 00503 00504 return((ColourModel) Info.SourceColourModel); 00505 }
|
|
|
Definition at line 1732 of file doccolor.cpp. 01733 { 01734 String_256 TempStr; 01735 01736 if (Info.IsSeparable) 01737 *Str += TEXT(" Sep "); 01738 else 01739 *Str += TEXT(" NotSep "); 01740 01741 if (Info.SourceColourModel == COLOURMODEL_INDEXED) 01742 { 01743 ENSURE(SourceColour.Indexed.Colour != NULL, 01744 "Corrupted DocColour (NULL IndexedColour ref) detected"); 01745 01746 String_64 *pIndexedName = SourceColour.Indexed.Colour->GetName(); 01747 // TempStr._MakeMsg(TEXT(" (#1%s) ref->"), 01748 // pIndexedName); // This is a reference to an indexed col 01749 // (*Str) += TempStr; 01750 (*Str) += TEXT(" ("); 01751 (*Str) += (*pIndexedName); 01752 (*Str) += TEXT(") ref ->"); 01753 SourceColour.Indexed.Colour->GetDebugDetails(Str); 01754 return; 01755 } 01756 01757 01758 if (Info.NoColour) 01759 TempStr._MakeMsg( TEXT(" colour=transparent\r\n")); 01760 else 01761 { 01762 ColourContext *cc = ColourContext::GetGlobalDefault((ColourModel) Info.SourceColourModel); 01763 ColourGeneric col; 01764 01765 String_32 ModelName; 01766 cc->GetModelName(&ModelName); 01767 cc->UnpackColour(&SourceColour, &col); 01768 01769 TempStr._MakeMsg( TEXT(" colour=#1%s(#2%ld, #3%ld, #4%ld, #5%ld)\r\n"), (TCHAR *) ModelName, 01770 (INT32) (col.Component1.MakeDouble()*100), (INT32) (col.Component2.MakeDouble()*100), 01771 (INT32) (col.Component3.MakeDouble()*100), (INT32) (col.Component4.MakeDouble()*100)); 01772 } 01773 01774 (*Str) += TempStr; 01775 }
|
|
||||||||||||||||
|
Definition at line 1678 of file doccolor.cpp. 01679 { 01680 ColourContextHSVT *CChsvt = (ColourContextHSVT *)ColourContext::GetGlobalDefault(COLOURMODEL_HSVT); 01681 ColourHSVT result; 01682 ColourPacked bob; 01683 01684 CChsvt->ConvertColour((DocColour *)this, (ColourGeneric *)&result); 01685 CChsvt->PackColour((ColourGeneric *)&result, (ColourPacked *)&bob); 01686 01687 *h = (INT32) bob.HSVT.Hue; 01688 *s = (INT32) bob.HSVT.Saturation; 01689 *v = (INT32) bob.HSVT.Value; 01690 }
|
|
|
access fn.
Definition at line 634 of file doccolor.cpp.
|
|
||||||||||||||||
|
Definition at line 1644 of file doccolor.cpp. 01645 { 01646 ColourContextRGBT *CCrgbt = (ColourContextRGBT *)ColourContext::GetGlobalDefault(COLOURMODEL_RGBT); 01647 ColourRGBT result; 01648 ColourPacked bob; 01649 01650 CCrgbt->ConvertColour((DocColour *)this, (ColourGeneric *)&result); 01651 CCrgbt->PackColour((ColourGeneric *)&result, (ColourPacked *)&bob); 01652 01653 *Red = (INT32) bob.RGBT.Red; 01654 *Green = (INT32) bob.RGBT.Green; 01655 *Blue = (INT32) bob.RGBT.Blue; 01656 }
|
|
|
Determine the native definition of the given colour Notes: If this is a reference to an IndexedColour, returns the colour of the referenced IndexedColour.
Definition at line 528 of file doccolor.cpp. 00529 { 00530 ENSURE(Info.SourceColourModel < MAX_COLOURMODELS, 00531 "DocColour based on illegal colour model!"); 00532 00533 // If colour is reference to indexed colour, ask the indexed colour for the 00534 // original colour definition, else return our own definition. 00535 if (Info.SourceColourModel == COLOURMODEL_INDEXED) 00536 { 00537 ENSURE(SourceColour.Indexed.Colour != NULL, 00538 "Corrupted DocColour (NULL IndexedColour ref) detected"); 00539 SourceColour.Indexed.Colour->GetSourceColour(Result); 00540 } 00541 else 00542 DEFAULTCONTEXT(Info.SourceColourModel)-> 00543 UnpackColour(&SourceColour, Result); 00544 00545 if (Info.ForceRounding) 00546 { 00547 // Our ForceRounding flag is on, so we must round all components to the closest 00548 // half percentage value. This is a bodge to correct for representational errors 00549 // in PANTONE library colours. 00550 double temp; 00551 00552 temp = Result->Component1.MakeDouble(); 00553 temp = (floor((temp * 200.0) + 0.5)) / 200.0; // Round to nearest 200th 00554 Result->Component1 = temp; 00555 00556 temp = Result->Component2.MakeDouble(); 00557 temp = (floor((temp * 200.0) + 0.5)) / 200.0; // Round to nearest 200th 00558 Result->Component2 = temp; 00559 00560 temp = Result->Component3.MakeDouble(); 00561 temp = (floor((temp * 200.0) + 0.5)) / 200.0; // Round to nearest 200th 00562 Result->Component3 = temp; 00563 00564 temp = Result->Component4.MakeDouble(); 00565 temp = (floor((temp * 200.0) + 0.5)) / 200.0; // Round to nearest 200th 00566 Result->Component4 = temp; 00567 } 00568 }
|
|
|
To determine which spot colour (if any) is the ultimate spot colour parent of this DocColour. (i.e. to see which spot plate a DocColour will appear on).
Definition at line 1525 of file doccolor.cpp. 01526 { 01527 IndexedColour *Parent = FindParentIndexedColour(); 01528 if (Parent != NULL) 01529 { 01530 if (!Parent->IsSpotOrTintOfSpot()) // If we aren't a TRUE tint, return NULL 01531 return(NULL); 01532 01533 Parent = Parent->FindOldestAncestor(); // ...else find our spot parent 01534 if (Parent->IsSpotOrTintOfSpot()) // (and check just to be really safe) 01535 return(Parent); 01536 } 01537 01538 // no parent, or it's not a spot colour 01539 return(NULL); 01540 }
|
|
|
As you might expect from the name this is a real bodge. Basically the named colour replacer used in the brush needs to store some colours which are converted index colours. To cut a long story short I'm looking at a deadline and this prevents an assert upon destruction, theres no reason for anyone else to use it.
Definition at line 696 of file doccolor.cpp. 00697 { 00698 Info.SourceColourModel = MAX_COLOURMODELS; 00699 }
|
|
|
Private shared code for construction of DocColour objects Initialises the 'Info' structure to default values Scope: private.
Definition at line 150 of file doccolor.cpp. 00151 { 00152 ENSURE((INT32) ColModel < MAX_COLOURMODELS, 00153 "Attempt to use illegal colour model!"); 00154 00155 Info.Reserved = 0; // Reserved - set to zero for safety 00156 00157 Info.OCContextHandle = 0; 00158 Info.SourceColourModel = ColModel; 00159 Info.CacheColourModel = COLOURMODEL_NOTCACHED; 00160 00161 Info.IsSeparable = TRUE; 00162 00163 Info.ForceRounding = FALSE; 00164 00165 Info.NoColour = FALSE; 00166 }
|
|
|
Definition at line 247 of file doccolor.h. 00247 { return(Info.ForceRounding); };
|
|
|
to identidy if this colour is named, or was created from a named colour. Note that not all colours that were created by Named colours will have the relevant flag set, as I have only just started using it (4/2000). This fn. was really designed to be used specifically by the brush attribute replace named colours system.
Definition at line 658 of file doccolor.cpp. 00659 { 00660 BOOL RetVal = FALSE; 00661 00662 // first try the parent colour 00663 IndexedColour* pParent = FindParentIndexedColour(); 00664 if (pParent != NULL) 00665 { 00666 if (pParent->IsNamed()) 00667 RetVal = TRUE; 00668 } 00669 00670 // now try the flags 00671 if (Info.Reserved == COL_NAMED) 00672 RetVal = TRUE; 00673 00674 return RetVal; 00675 }
|
|
|
Determines if a colour's "IsSeparable" flag is set.
Definition at line 390 of file doccolor.h. 00391 { 00392 return(Info.IsSeparable); 00393 }
|
|
|
Determines if a colour's "no colour" flag is set.
Definition at line 370 of file doccolor.h.
|
|
|
Definition at line 1481 of file doccolor.cpp. 01482 { 01483 ENSURE(Other != NULL, 01484 "NULL IndexedColour pointer passed to DocColour::MakeRefToIndexedColour!"); 01485 01486 if (Info.SourceColourModel == COLOURMODEL_INDEXED) 01487 { 01488 ENSURE(SourceColour.Indexed.Colour != NULL, 01489 "Corrupted DocColour (NULL IndexedColour ref) detected"); 01490 SourceColour.Indexed.Colour->DecrementUsage(); 01491 } 01492 01493 Info.NoColour = FALSE; 01494 Info.SourceColourModel = COLOURMODEL_INDEXED; 01495 Info.CacheColourModel = COLOURMODEL_NOTCACHED; // NEVER cache indexed colours 01496 Info.OCContextHandle = 0; 01497 Info.IsSeparable = TRUE; // IxCols are always separable 01498 01499 SourceColour.Indexed.Colour = Other; 01500 Other->IncrementUsage(); 01501 }
|
|
||||||||||||||||
|
DocColour assignment - Makes this DocColour a reference to the given Indexed Colour. The Indexed Colour cannot be deleted until this DocColour releases this claim upon it (which occurs when it is deleted or re-assigned).
Definition at line 1466 of file doccolor.cpp. 01467 { 01468 #ifdef TRACECOLOURIX 01469 TRACE( _T(">> DocColour @ %x ref ColourIx: %x @ %s line %ld\n"), (INT32)this, (INT32)Other, TheFile, TheLine); 01470 #endif 01471 01472 // Disable the debugging macro so that the function code will compile 01473 #undef MakeRefToIndexedColour 01474 // --------- 01475 01476 MakeRefToIndexedColour(Other); 01477 }
|
|
||||||||||||||||||||||||||||
|
"Constructor" for a DocColour - generates a blended DocColour The start and end colours are blended to create this new DocColour. The amount by which they are mixed is determined by BlendFraction. The blend occurs in the colourspace described by BlendContext. Note that BlendContext may be NULL, in which case the default context for the BlendStart colour will be used. However, this is not recommended, as this will result in a blend which may be incorrect for the context(s) in use in a given document, which could give seriously wonky colours!
BlendFraction - The amount by which the two colours should be blended, in the range 0.0 to 1.0. Blending is linear in the given colourspace, achieved by the equation Result = (BlendStart * (1.0-BlendFraction)) + (BlendEnd * BlendFraction) BlendContext - the colour context in which the blend will take place (may be NULL, but this is NOT recommended) (Note that this is ignored if either colour is a Spot) (Note that if both end colours are CMYK, and Mix effect is used, a CMYK context is used instead, so that CMYK grads colour separate properly) BlendTheLongWay - (ONLY used if the BlendContext points to an HSV context) This indicates whether to do 'rainbow' (shortest distance- FALSE) or 'alt-rainbow' (longest distance- TRUE) HSV colour blending. OutputContext - Normally, this should be NULL. However, if you're doing a colour separation involving spot colours, you should pass the output colour context in here, so that spots can be correctly separated. The output for mixing a spot colour will then be a greyscale ink intensity, correctly colour separated, and with its IsSeparable flag FALSE so that it is not colour separated or corrected a second time when output. It is safe to always pass the output context in here, as this function will always work out the appropriate behviour. If blending is requested in HSV space, the extra parameter BlendTheLongWay is required, to determine if blending is done in a "Rainbow" or "Alt-Rainbow" fashion. Notes: Note that although this may be slow, you must mix colours using this method, or colour correction/separation may not occur. The blend method specified by BlendContext & BlendTheLongWay is ignored if either of the colours is a spot colour - these are always coerced into simple "Mix" fills/blends, as otherwise the printed output and colour representation on screen will be totally different! If both end colours reference the same IndexedColour, and the mixing method is Mix (RGB) or Rainbow (HSV, BlendTheLongWay==FALSE), then all intermediate colours are identical, and are thus returned referencing the original indexed colour. If both the end colours are tints of the same spot colour, then two things can occur: If OutputContext != NULL, we presume the mix is temporary for rendering to that context, so produce an RGB mix or separated Ink density value for the context. If OutputContext == NULL, we presume you're doing a make shapes on a blend or similar, so we create a new local colour for each mix, which is a permanent proper tint of the parent spot ink. Definition at line 777 of file doccolor.cpp. 00780 { 00781 // if (BlendFraction >= 1.0) 00782 // BlendFraction = 0.999999999; 00783 00784 // ERROR3IF(BlendFraction < 0.0 || BlendFraction > 1.0, 00785 // "DocColour::DocColour Blend: Illegal Blend fraction!"); 00786 00787 ERROR3IF(BlendStart == NULL || BlendEnd == NULL, 00788 "DocColour::DocColour Blend: NULL input parameters!"); 00789 00790 // Make sure that this colour is not a reference to an IndexedColour, otherwise 00791 // if/when we InitialiseInfoField() below, we'll forget the reference, and trigger 00792 // lots of bogus "IndexedColour deleted while in use" warnings 00793 if (Info.SourceColourModel == COLOURMODEL_INDEXED) 00794 { 00795 SourceColour.Indexed.Colour->DecrementUsage(); 00796 Info.SourceColourModel = COLOURMODEL_RGBT; 00797 } 00798 00799 // If either the start of end colour is a spot/tint colour, then we will coerce 00800 // this mix into a simple RGB mix, not a Hue mix, by grabbing the default RGB context 00801 // We also special-case a Mix/Rainbow from an IndexedColour to itself, by simply making 00802 // the mixed step another reference to that colour (but not for alt-rainbow!) 00803 BOOL IncludesSpots = FALSE; // Remember if we've got to worry about spots 00804 00805 IndexedColour *StartParent = BlendStart->FindParentIndexedColour(); 00806 IndexedColour *EndParent = BlendEnd->FindParentIndexedColour(); 00807 00808 00809 // --- Are blend start/end colours identical? - we might optimise them out if they are 00810 if (StartParent != NULL && StartParent == EndParent) 00811 { 00812 // If it's an RGB Mix or an HSV Rainbow (short way) then all mixes are identical to 00813 // the original colour, so just return that instead. 00814 if ( BlendContext != NULL && 00815 ( BlendContext->GetColourModel () == COLOURMODEL_RGBT || 00816 ( BlendContext->GetColourModel () == COLOURMODEL_HSVT && !BlendTheLongWay ) ) ) 00817 { 00818 // Make ourselves a reference to the parent colour 00819 MakeRefToIndexedColour ( StartParent ); 00820 return; 00821 } 00822 } 00823 00824 00825 // --- Determine if one or both of the colours are spot/tint colours 00826 // (When separating, we must treat blends including spot colours very specially) 00827 if (StartParent != NULL && StartParent->IsSpotOrTintOfSpot()) 00828 IncludesSpots = TRUE; 00829 else if (EndParent != NULL && EndParent->IsSpotOrTintOfSpot()) 00830 IncludesSpots = TRUE; 00831 00832 if (IncludesSpots) 00833 { 00834 |