#include <colcontx.h>
Inheritance diagram for ColourContextHSVT:
Public Member Functions | |
ColourContextHSVT (View *Scope) | |
Constructor for an HSVT Colour context. | |
void | ConvertToCIET (ColourGeneric *Source, DColourCIET *Result) |
Converts the given colour from our HSVT colourspace to CIET colourspace Notes: -. | |
void | ConvertFromCIET (DColourCIET *Source, ColourGeneric *Result) |
Converts the given colour to our HSVT colourspace from CIET colourspace Notes: -. | |
void | CreateExternalTransform () |
Create an external transform to be used during colour conversions from HSV to the current RCS space. This function uses the Winoil CMS Manager to create the transform. Both forward and backward transforms use a physical printer profile description. | |
virtual void | GetModelName (StringBase *Result) |
Returns the name of this context's colour model Notes:. | |
virtual BOOL | GetComponentName (INT32 ComponentID, StringBase *Result, BOOL LongName=FALSE) |
Returns the name of one of this context's colour components. | |
virtual UINT32 | GetComponentCount () |
Provides number of components in the colour context's colour model. | |
virtual void | ApplyTint (ColourValue TintFraction, ColourGeneric *SourceAndResult) |
Tints a colour (mixes it with white). | |
virtual void | ApplyShade (ColourValue XFraction, ColourValue YFraction, ColourGeneric *SourceAndResult) |
Shades a colour (tweaks the saturation and value in a relative way). | |
virtual void | GetWhite (ColourGeneric *Result) |
An easy way to get a colour definition in this colour model which is white (paper colour). | |
Protected Member Functions | |
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. | |
virtual UnitGroup ** | GetComponentUnitGroups () |
Provides an array of UnitGroups primarily for use by the base class (ColourContext) members Set/GetComponentUnitGroup(). | |
Private Types | |
enum | { MAX_COMPONENTS = 3 } |
Static Private Attributes | |
static UnitGroup * | m_pUnitGroupArray [MAX_COMPONENTS] |
Friends | |
class | DocColour |
class | ColourContextList |
class | GRenderRegion |
class | OSRenderRegion |
Definition at line 1159 of file colcontx.h.
|
Definition at line 1193 of file colcontx.h. 01194 { 01195 MAX_COMPONENTS = 3 // Number of components in colour context 01196 };
|
|
Constructor for an HSVT Colour context.
Definition at line 3047 of file colcontx.cpp. 03048 : ColourContext(Scope) 03049 { 03050 ColModel = COLOURMODEL_HSVT; 03051 03052 CreateExternalTransform(); 03053 }
|
|
Shades a colour (tweaks the saturation and value in a relative way).
SourceAndResult - The source colour to be tinted, as defined in this colour model
Implements ColourContext. Definition at line 3577 of file colcontx.cpp. 03579 { 03580 ColourHSVT *Result = (ColourHSVT *) SourceAndResult; 03581 03582 ERROR3IF(XFraction < FIXED24(-1.0) || XFraction > FIXED24(1.0), "Illegal X Shading value"); 03583 ERROR3IF(YFraction < FIXED24(-1.0) || YFraction > FIXED24(1.0), "Illegal Y Shading value"); 03584 03585 // Adjust the Saturation according to XFraction 03586 if (XFraction != FIXED24(0.0)) 03587 { 03588 if (XFraction < FIXED24(0.0)) 03589 { 03590 XFraction = -XFraction; 03591 Result->Saturation = Result->Saturation * (FIXED24(1.0) - XFraction); 03592 } 03593 else 03594 Result->Saturation = XFraction + Result->Saturation * (FIXED24(1.0) - XFraction); 03595 } 03596 03597 03598 // Adjust the Value according to YFraction 03599 if (YFraction != FIXED24(0.0)) 03600 { 03601 if (YFraction < FIXED24(0.0)) 03602 { 03603 YFraction = -YFraction; 03604 Result->Value = Result->Value * (FIXED24(1.0) - YFraction); 03605 } 03606 else 03607 Result->Value = YFraction + Result->Value * (FIXED24(1.0) - YFraction); 03608 } 03609 }
|
|
Tints a colour (mixes it with white).
Implements ColourContext. Definition at line 3527 of file colcontx.cpp. 03528 { 03529 ColourHSVT *Result = (ColourHSVT *) SourceAndResult; 03530 03531 if (TintFraction <= FIXED24(0.0)) // 0% tint = White 03532 { 03533 Result->Saturation = 0; 03534 Result->Value = FIXED24(1.0); 03535 return; 03536 } 03537 03538 if (TintFraction >= FIXED24(1.0)) // The Result colour is identical to the source 03539 return; 03540 03541 // Otherwise, tint the colour... 03542 // Hue remains constant 03543 Result->Saturation = Result->Saturation * TintFraction; 03544 Result->Value = FIXED24(1.0) - (TintFraction - (Result->Value * TintFraction)); 03545 }
|
|
Converts the given colour to our HSVT colourspace from CIET colourspace Notes: -.
Implements ColourContext. Definition at line 3203 of file colcontx.cpp. 03204 { 03205 ENSURE(UsageCount > 0, "Colour context being used when not initialised!"); 03206 03207 // First, we'll convert from CIE to RGB 03208 double R, G, B; 03209 03210 #ifndef NO_XARACMS 03211 // If we've got a CMS manager, use it, else use the version 1.1 bodge 03212 XaraCMS* lpCMSMan = GetApplication()->GetCMSManager(); 03213 03214 if (lpCMSMan != NULL) 03215 { 03216 // The new colour calibration method 03217 CMSColour icol, ocol; 03218 icol.c0 = Source->X; 03219 icol.c1 = Source->Y; 03220 icol.c2 = Source->Z; 03221 03222 // If we have no colour transform, or if we don't want the colour corrected/separated, 03223 // then we will just do a "logical" conversion. 03224 if (CMSTransform == NULL || (ColPlate != NULL && ColPlate->IsDisabled())) 03225 lpCMSMan->ConvCIEXYZtoRGB(icol, ocol); 03226 else 03227 lpCMSMan->GTransform(CMSTransform, cmsReverse, icol, ocol); 03228 03229 R = ocol.c0; 03230 G = ocol.c1; 03231 B = ocol.c2; 03232 } 03233 else 03234 #endif 03235 { 03236 // The old rgb system 03237 R = Source->X; 03238 G = Source->Y; 03239 B = Source->Z; 03240 } 03241 03242 03243 // Now, convert the RGB value into HSV 03244 double Min, Max, Delta, H, S, V; 03245 Min = min(R, G); 03246 Min = min(Min, B); 03247 Max = max(R, G); 03248 Max = max(Max, B); 03249 03250 V = Max; 03251 Delta = Max - Min; 03252 03253 if (fabs(Delta) > 0.000001) 03254 { 03255 if (Max > 0.0) 03256 S = Delta / Max; 03257 else 03258 S = 0.0; 03259 03260 if (R == Max) 03261 H = (G - B) / Delta; 03262 else if (G == Max) 03263 H = 2.0 + (B - R) / Delta; 03264 else 03265 H = 4 + (R - G) / Delta; 03266 03267 03268 H = H / 6.0; 03269 if (H < 0.0) H += 1.0; 03270 } 03271 else 03272 { 03273 H = S = 0.0; 03274 } 03275 03276 ((ColourHSVT *)Result)->Hue = H; 03277 ((ColourHSVT *)Result)->Saturation = S; 03278 ((ColourHSVT *)Result)->Value = V; 03279 ((ColourHSVT *)Result)->Transparent = 0; //Source->Transparent; 03280 }
|
|
Converts the given colour from our HSVT colourspace to CIET colourspace Notes: -.
Implements ColourContext. Definition at line 3109 of file colcontx.cpp. 03110 { 03111 ENSURE(UsageCount > 0, "Colour context being used when not initialised!"); 03112 03113 // First, let's convert the HSV into RGB 03114 FIXED24 H,S,V, R,G,B, F, P,Q,T; // Sorry, I just have to override the style guide here! 03115 03116 H = ((ColourHSVT *)Source)->Hue; 03117 S = ((ColourHSVT *)Source)->Saturation; 03118 V = ((ColourHSVT *)Source)->Value; 03119 03120 if (S == FIXED24(0)) 03121 { 03122 R = V; 03123 G = V; 03124 B = V; 03125 } 03126 else 03127 { 03128 H *= 6; 03129 INT32 I = H.MakeInt(); 03130 F = H - I; 03131 P = V * (1.0 - S); 03132 Q = V * (1.0 - (S * F)); 03133 T = V * (1.0 - (S * (1.0 - F))); 03134 03135 switch (I) 03136 { 03137 case 1: R = Q; G = V; B = P; break; 03138 case 2: R = P; G = V; B = T; break; 03139 case 3: R = P; G = Q; B = V; break; 03140 case 4: R = T; G = P; B = V; break; 03141 case 5: R = V; G = P; B = Q; break; 03142 default: R = V; G = T; B = P; break; 03143 } 03144 } 03145 03146 #ifndef NO_XARACMS 03147 // Now, convert the RGB to CIE 03148 // If we've got a CMS manager, use it, else use the version 1.1 bodge 03149 XaraCMS* lpCMSMan = GetApplication()->GetCMSManager(); 03150 03151 if (lpCMSMan != NULL) 03152 { 03153 // The new colour calibration method 03154 CMSColour icol, ocol; 03155 icol.c0 = R.MakeDouble(); 03156 icol.c1 = G.MakeDouble(); 03157 icol.c2 = B.MakeDouble(); 03158 03159 // If we have no colour transform, or if we don't want the colour corrected/separated, 03160 // then we will just do a "logical" conversion. 03161 if (CMSTransform == NULL || (ColPlate != NULL && ColPlate->IsDisabled())) 03162 lpCMSMan->ConvRGBtoCIEXYZ(icol, ocol); 03163 else 03164 lpCMSMan->GTransform(CMSTransform, cmsForward, icol, ocol); 03165 03166 Result->X = ocol.c0; 03167 Result->Y = ocol.c1; 03168 Result->Z = ocol.c2; 03169 Result->Transparent = 0.0;//bob->Transparent; 03170 } 03171 else 03172 #endif 03173 { 03174 // The old rgb system 03175 Result->X = R.MakeDouble(); 03176 Result->Y = G.MakeDouble(); 03177 Result->Z = B.MakeDouble(); 03178 Result->Transparent = 0;//((ColourHSVT *)Source)->Transparent; 03179 } 03180 }
|
|
Create an external transform to be used during colour conversions from HSV to the current RCS space. This function uses the Winoil CMS Manager to create the transform. Both forward and backward transforms use a physical printer profile description.
Reimplemented from ColourContext. Definition at line 3070 of file colcontx.cpp. 03071 { 03072 #ifndef NO_XARACMS 03073 CMSColourSpace cmsSpace; 03074 XaraCMS* lpCMSMan = GetApplication()->GetCMSManager(); 03075 03076 if (lpCMSMan != NULL) 03077 { 03078 // first read our internal colour calibration space 03079 lpCMSMan->GetLogicalProfile(&cmsSpace); 03080 // set this as the active colour profile 03081 UINT32 err = lpCMSMan->SetProfile(cmsSpace); 03082 // if we haven't got an error, create that transform 03083 if (err==0) 03084 CMSTransform = lpCMSMan->CreateTransform(DISPLAY_RCS); 03085 } 03086 #endif 03087 }
|
|
Provides number of components in the colour context's colour model.
Implements ColourContext. Definition at line 3495 of file colcontx.cpp. 03496 { 03497 return MAX_COMPONENTS; 03498 }
|
|
Returns the name of one of this context's colour components.
Implements ColourContext. Definition at line 3414 of file colcontx.cpp. 03415 { 03416 UINT32 StringID = 0; 03417 BOOL Used = TRUE; 03418 03419 switch(ComponentID) 03420 { 03421 case 1: 03422 StringID = (LongName) ? _R(IDS_COLCOMPL_HUE) : _R(IDS_COLCOMP_HUE); 03423 break; 03424 03425 case 2: 03426 StringID = (LongName) ? _R(IDS_COLCOMPL_SATURATION) : _R(IDS_COLCOMP_SATURATION); 03427 break; 03428 03429 case 3: 03430 StringID = (LongName) ? _R(IDS_COLCOMPL_VALUE) : _R(IDS_COLCOMP_VALUE); 03431 break; 03432 03433 #ifdef TRANSPARENTCOLOUR 03434 default: 03435 StringID = _R(IDS_COLCOMP_TRANS); 03436 break; 03437 #else 03438 default: 03439 Used = FALSE; 03440 break; 03441 #endif 03442 } 03443 03444 if (Result != NULL && StringID != 0) 03445 *Result = String_32(StringID); 03446 03447 return(Used); 03448 }
|
|
Provides an array of UnitGroups primarily for use by the base class (ColourContext) members Set/GetComponentUnitGroup().
Implements ColourContext. Definition at line 3469 of file colcontx.cpp. 03470 { 03471 return m_pUnitGroupArray; 03472 }
|
|
Returns the name of this context's colour model Notes:.
Implements ColourContext. Definition at line 3375 of file colcontx.cpp. 03376 { 03377 ENSURE(Result != NULL, "ColourContext::GetModelName called with NULL result pointer!"); 03378 03379 *Result = String_32(_R(IDS_COLMODEL_HSVT)); 03380 }
|
|
An easy way to get a colour definition in this colour model which is white (paper colour).
Implements ColourContext. Definition at line 3628 of file colcontx.cpp. 03629 { 03630 ColourHSVT *hsvt = (ColourHSVT *) Result; 03631 hsvt->Hue = hsvt->Saturation = 0; 03632 hsvt->Value = 1.0; 03633 hsvt->Transparent = 0; 03634 }
|
|
Converts 128-bit colour representation to 32-bit packed form.
Scope: Private (used internally by friend class DocColour)
Reimplemented from ColourContext. Definition at line 3309 of file colcontx.cpp. 03310 { 03311 PColourHSVT *bob = (PColourHSVT *) Result; 03312 03313 bob->Hue = PackColour360(Source->Component1); 03314 bob->Saturation = PackColour256(Source->Component2); 03315 bob->Value = PackColour256(Source->Component3); 03316 bob->Transparent = 0; //PackColour128(Source->Transparent); 03317 }
|
|
Converts 32-bit packed colour representation to 128-bit form.
Scope: Private (used internally by friend class DocColour)
Reimplemented from ColourContext. Definition at line 3345 of file colcontx.cpp. 03346 { 03347 PColourHSVT *bob = (PColourHSVT *) Source; 03348 03349 UnpackColour360(bob->Hue, &Result->Component1); 03350 UnpackColour256(bob->Saturation, &Result->Component2); 03351 UnpackColour256(bob->Value, &Result->Component3); 03352 Result->Component4 = 0;//UnpackColour128(bob->Transparent, &Result->Transparent); 03353 }
|
|
Reimplemented from ColourContext. Definition at line 1162 of file colcontx.h. |
|
Reimplemented from ColourContext. Definition at line 1161 of file colcontx.h. |
|
Reimplemented from ColourContext. Definition at line 1164 of file colcontx.h. |
|
Reimplemented from ColourContext. Definition at line 1165 of file colcontx.h. |
|
Initial value: Definition at line 1197 of file colcontx.h. |