colmodel.h

Go to the documentation of this file.
00001 // $Id: colmodel.h 751 2006-03-31 15:43:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 // colmodel.h - Camelot colour models
00099 
00100 // This defines the available colour models and storage structures for them
00101 // The actual conversions between colours in various colur models are handled
00102 // by colour contexts, which incorporate colour models plus conversion modifiers
00103 // such as gamma correction etc. See colcontx.h
00104 
00105 
00106 #ifndef INC_COLMODEL
00107 #define INC_COLMODEL
00108 
00109 
00110 #ifndef INC_FIXED24
00111 #include "fixed24.h"
00112 #endif
00113 
00114 
00115 
00116 /********************************************************************************************
00117 
00118 < TransType
00119 < TransparencyType
00120 
00121     Comment:    Camelot supports 4 different models for transparency.
00122                 The TransType enumerated type enumerates the 4 possible values:
00123 
00124                 TRANSTYPE_NONE, _REFLECTIVE, _SUBTRACTIVE, _ADDITIVE.
00125 
00126                 TRANSTYPE_DEFAULT is set to the default value with which all
00127                 Doc/Indexed Colour objects will be initially created. (Current = 1)
00128 
00129     SeeAlso:    DocColour::SetTransparencyType; IndexedColour::SetTransparencyType
00130         
00131 ********************************************************************************************/
00132 
00133 typedef enum
00134 {
00135     TRANSTYPE_MINIMUM       = 0,
00136 
00137     TRANSTYPE_NONE          = 0,
00138 
00139     TRANSTYPE_DEFAULT       = 1,
00140 
00141     TRANSTYPE_REFLECTIVE    = 1,
00142     TRANSTYPE_SUBTRACTIVE   = 2,
00143     TRANSTYPE_ADDITIVE      = 3,
00144 
00145     TRANSTYPE_MAXIMUM       = 3
00146 } TransType;
00147 
00148 
00149 
00150 /********************************************************************************************
00151 
00152 < ColourModel
00153 
00154   Comment:
00155     Enumerated type of the available colour models. There can be no more
00156     than 16 models (as references to colour models are 4-bit fields)
00157 
00158     MonoOn
00159     typedef enum
00160     {
00161         COLOURMODEL_INDEXED     = 0,        //  0 Private to Colour system
00162         COLOURMODEL_NOTCACHED   = 0,        //  0 Private to Colour system
00163 
00164         COLOURMODEL_CIET,                   //  1 CIE coordinate (X,Y,Z), Trans
00165         COLOURMODEL_RGBT,                   //  2 Red, Green, Blue, Trans
00166         COLOURMODEL_CMYK,                   //  3 Cyan, Magenta, Yellow, Key
00167         COLOURMODEL_HSVT,                   //  4 Hue, Saturation, Value, Trans
00168         COLOURMODEL_GREYT,                  //  5 Greyscale intensity, Trans
00169 
00170         MAX_COLOURMODELS                    //  6 Number of available models
00171     } ColourModel;
00172     MonoOff
00173 
00174   SeeAlso:
00175     Keyword MAX_COLOURMODELS
00176     
00177 ********************************************************************************************/
00178 
00179 
00180 /********************************************************************************************
00181 
00182 < MAX_COLOURMODELS
00183 
00184   Comment:
00185     This contains the number of colour models available for use in Camelot.
00186     The main use for this is internal to the colour system, for processing all
00187     colour models, using a loop of the form:
00188         MonoOn
00189         for (INT32 colourmodel = 0; colourmodel < MAX_COLOURMODELS; colourmodel++)
00190             ... Do something relating to colour model 'colourmodel'...;
00191         MonoOff
00192         
00193   SeeAlso:  Keyword ColourModel
00194     
00195 ********************************************************************************************/
00196 
00197 typedef enum
00198 {
00199     COLOURMODEL_INDEXED     = 0,        //  0 Reference to an indexed colour
00200                                         //      (ONLY valid for SourceColourModel
00201                                         //      field of immediate colours)
00202     COLOURMODEL_NOTCACHED   = 0,        //  0 Indicator that the cache is invalid
00203                                         //      (ONLY valid for CacheColourModel
00204                                         //      field of immediate colours)
00205 
00206     COLOURMODEL_CIET,                   //  1 CIE coordinate (X,Y,Z), Transparent
00207     COLOURMODEL_RGBT,                   //  2 Red, Green, Blue, Transparent
00208     COLOURMODEL_CMYK,                   //  3 Cyan, Magenta, Yellow, Key
00209     COLOURMODEL_HSVT,                   //  4 Hue, Saturation, Value, Transparent
00210     COLOURMODEL_GREYT,                  //  5 Greyscale intensity, Transparent
00211     COLOURMODEL_WEBRGBT,                //  6 Same as COLOURMODEL_RGBT; but allows us
00212                                         //  to (correctly) provide a new ColourContext
00213                                         //  that can be selected within the colour editor
00214                                         //  for hex input (but still functions internally
00215                                         //  as a COLOURMODEL_RGBT
00216 
00217     // Insert new colour models here...
00218 
00219     MAX_COLOURMODELS                    // This is automagically set to the
00220                                         // number of available models.
00221                                         // You MAY:
00222                                         //   for (cm=0; cm<MAX_COLOURMODELS; cm++)
00223                                         // You may NOT:
00224                                         //   for (cm=0; cm<16; cm++)
00225 } ColourModel;
00226 
00227 
00228 
00230 // Colour definition structures
00231 // These encode a colour in one of the available colour models
00232 //
00233 // Two types of colour definition exist:
00234 // PColourABCD:     Packed Colour   - Must fit within  32 bits of memory
00235 //                  These are typically built of up to 4 8-bit ColourValues
00236 //
00237 // ColourABCD:      Normal colour   - Must fit within 128 bits of memory
00238 //                  These are typically built of up to 4 32-bit PColourValues
00239 //
00240 // NOTE however, that some models (e.g. HSVT) choose to divide the available
00241 // bits up in a different fashion to the typical colour models.
00242 //
00243 // IMPORTANT NOTE!!
00244 //   It is essential that all ColourXXXX structures are exactly 4 ColourValues
00245 //   wide, and that any 'Transparent' component is component 4, so that they
00246 //   are easily interchangable.
00247 
00248 
00249 typedef UINT32  PColourValue;   // 4 8-bit PColourValues make a PColour
00250 typedef FIXED24         ColourValue;    // 4 32-bit ColourValues make an Colour
00251 
00252 
00253 
00254 /********************************************************************************************
00255 
00256 < ColourRGBT
00257 
00258   Comment:
00259     Components = Red, Green, Blue, Transparent
00260 
00261     This structure defines a colour in terms of RGBT components.
00262 
00263     Each component is represented as an 8.24 bit fixed point fraction between
00264     0.0 (0x00000000) and 1.0 (0x01000000).
00265     
00266 
00267   SeeAlso:  ColourModel; ColourGeneric; ColourCMYK; ColourHSVT;
00268             ColourGreyT; ColourCIET; IndexedColour
00269     
00270 ********************************************************************************************/
00271 
00272 typedef struct                          // --- RGBT ---
00273 {
00274     PColourValue Red            : 8;
00275     PColourValue Green          : 8;
00276     PColourValue Blue           : 8;
00277     PColourValue Transparent    : 8;
00278 } PColourRGBT;
00279 
00280 typedef struct
00281 {
00282     ColourValue Red;
00283     ColourValue Green;
00284     ColourValue Blue;
00285     ColourValue Transparent;
00286 } ColourRGBT;
00287 
00288 /********************************************************************************************
00289 
00290 < ColourCMYK
00291 
00292   Comment:
00293     Components = Cyan, Magenta, Yellow, Key
00294 
00295     This structure defines a colour in terms of CMYK components.
00296 
00297     Each component is represented as an 8.24 bit fixed point fraction between
00298     0.0 (0x00000000) and 1.0 (0x01000000).
00299     
00300 
00301   SeeAlso:  ColourModel; ColourGeneric; ColourRGBT; ColourHSVT;
00302             ColourGreyT; ColourCIET; IndexedColour
00303     
00304 ********************************************************************************************/
00305 
00306 typedef struct                          // --- CMYK ---
00307 {
00308     PColourValue Cyan           : 8;
00309     PColourValue Magenta        : 8;
00310     PColourValue Yellow         : 8;
00311     PColourValue Key            : 8;
00312 } PColourCMYK;
00313 
00314 typedef struct
00315 {
00316     ColourValue Cyan;
00317     ColourValue Magenta;
00318     ColourValue Yellow;
00319     ColourValue Key;
00320 } ColourCMYK;
00321 
00322 
00323 /********************************************************************************************
00324 
00325 < ColourHSVT
00326 
00327   Comment:
00328     Components = Hue, Saturation, Value, Transparent
00329 
00330     This structure defines a colour in terms of HSVT components.
00331 
00332     Each component is represented as an 8.24 bit fixed point fraction between
00333     0.0 (0x00000000) and 1.0 (0x01000000).
00334     
00335 
00336   SeeAlso:  ColourModel; ColourGeneric; ColourRGBT; ColourCMYK;
00337             ColourGreyT; ColourCIET; IndexedColour
00338     
00339 ********************************************************************************************/
00340 
00341 typedef struct                          // --- HSVT ---
00342 {
00343     PColourValue Saturation     : 8;
00344     PColourValue Value          : 8;
00345     PColourValue Hue            : 9;
00346     PColourValue Transparent    : 7;
00347 } PColourHSVT;
00348 
00349 typedef struct
00350 {
00351     ColourValue Hue;
00352     ColourValue Saturation;
00353     ColourValue Value;
00354     ColourValue Transparent;
00355 } ColourHSVT;
00356 
00357 
00358 /********************************************************************************************
00359 
00360 < ColourGreyT
00361 
00362   Comment:
00363     Components = Intensity, Transparent 
00364 
00365     This structure defines a colour in terms of IT components.
00366 
00367     Each component is represented as an 8.24 bit fixed point fraction between
00368     0.0 (0x00000000) and 1.0 (0x01000000).
00369     
00370 
00371   SeeAlso:  ColourModel; ColourGeneric; ColourRGBT; ColourCMYK; ColourHSVT;
00372             ColourCIET; IndexedColour
00373     
00374 ********************************************************************************************/
00375 
00376 typedef struct                          // --- GreyT ---
00377 {
00378     PColourValue Intensity      : 8;
00379     PColourValue Reserved       : 16;
00380     PColourValue Transparent    : 8;
00381 } PColourGreyT;
00382 
00383 typedef struct
00384 {
00385     ColourValue Intensity;
00386     ColourValue Reserved1;
00387     ColourValue Reserved2;
00388     ColourValue Transparent;
00389 } ColourGreyT;
00390 
00391 
00392 
00393 /********************************************************************************************
00394 
00395 < ColourCIET
00396 
00397   Comment:
00398     Components = X, Y, Z, Transparent
00399 
00400     This structure defines a colour in terms of XYZT components.
00401     The X,Y,Z define a point in the CIE colourspace.
00402 
00403     Each component is represented as an 8.24 bit fixed point fraction between
00404     0.0 (0x00000000) and 1.0 (0x01000000).
00405     
00406 
00407   SeeAlso:  ColourModel; ColourGeneric; ColourRGBT; ColourCMYK; ColourHSVT;
00408             ColourGreyT; ColourCIET; IndexedColour
00409     
00410 ********************************************************************************************/
00411 
00412 typedef struct                          // --- CIET ---
00413 {
00414     PColourValue X              : 8;
00415     PColourValue Y              : 8;
00416     PColourValue Z              : 8;
00417     PColourValue Transparent    : 8;
00418 } PColourCIET;
00419 
00420 typedef struct
00421 {
00422     ColourValue X;
00423     ColourValue Y;
00424     ColourValue Z;
00425     ColourValue Transparent;
00426 } ColourCIET;
00427 
00428 typedef struct
00429 {
00430     double X;
00431     double Y;
00432     double Z;
00433     double Transparent;
00434 } DColourCIET;
00435 
00436 class IndexedColour;
00437 typedef struct                          // --- Indexed ---
00438 {
00439     IndexedColour *Colour;
00440 } PColourIndexed;
00441 
00442 
00443 
00444 
00445 
00446 /********************************************************************************************
00447 
00448 < ColourGeneric
00449 
00450   Comment:
00451     Components = Component1, Component2, Component3, Component4
00452 
00453     This structure defines a colour in terms of 4 generic components.
00454 
00455     It is only to be used internally to the colour system to provide a generic
00456     means of conversion between 8-bit and 32-bit component representations.
00457     (Note that this means colours such as HSVT cannot be converted via the
00458     generic system, as they don't use generic 8-bit fields)
00459     
00460 
00461   SeeAlso:  ColourModel; ColourGeneric; ColourRGBT; ColourCMYK; ColourHSVT;
00462             ColourGreyT; ColourCIET; IndexedColour
00463     
00464 ********************************************************************************************/
00465 
00466 typedef struct                          // --- CIET ---
00467 {
00468     PColourValue Component1     : 8;
00469     PColourValue Component2     : 8;
00470     PColourValue Component3     : 8;
00471     PColourValue Component4     : 8;
00472 } PColourGeneric;
00473 
00474 typedef struct
00475 {
00476     ColourValue Component1;
00477     ColourValue Component2;
00478     ColourValue Component3;
00479     ColourValue Component4;
00480 } ColourGeneric;
00481 
00482 
00483 
00484 
00486 // Packed Colour Block
00487 // This is a union of all Normal (32-bit) colour definition structures
00488 
00489 typedef union
00490 {
00491 //  PColourGeneric  Generic;    -- This is an explicit cast, only for internal use
00492     PColourRGBT     RGBT;
00493     PColourCMYK     CMYK;
00494     PColourHSVT     HSVT;
00495     PColourGreyT    GreyT;
00496     PColourCIET     CIET;
00497     PColourIndexed  Indexed;
00498 } ColourPacked;
00499 
00500 
00501 
00502 
00503 #if FALSE
00504     // The following can't be used (as we are using FIXED24, a class, the
00505     // union gets upset about it having default constructors and stuff, making
00506     // it difficult/impossible to use. Seeing no particular need for a ColourGeneric
00507     // other than making the colour-class internals neater, I've decided to
00508     // discontinue it - if it becomes absolutely necessary in the future, a
00509     // ColourGeneric class with special access methods can be made.
00510 
00511     // The internal structure used to store the info is now a ColourGeneric.
00512 
00513 
00514 /********************************************************************************************
00515 
00516  ColourDefn
00517 
00518 Comment :
00519     This union contains the definition of a single colour in one of the available
00520     colour models. The data is stored in 4 model-specific components, each of which
00521     is stored as an 8.24-bit fixed-point fractional value, i.e.
00522         0.0 is represented as   0x00000000
00523         0.5                     0x007fffff
00524         1.0                     0x01000000
00525     Colours are described and processed in this format wherever possible (although a
00526     low-precision packed form is available for rendering etc - see colmodel.h - it is
00527     desirable that we use proper precision in colour calculations)
00528     
00529 
00530 See Also:   ColourModel; ColourRGBT; ColourCMYK; ColourHSVT;
00531             ColourGreyT; ColourCIET; IndexedColour
00532     
00533 ********************************************************************************************/
00534 
00535 typedef union
00536 {
00537 //  ColourGeneric   Generic;    -- This is an explicit cast, only for internal use
00538     ColourRGBT      RGBT;
00539     ColourCMYK      CMYK;
00540     ColourHSVT      HSVT;
00541     ColourGreyT     GreyT;
00542     ColourCIET      CIET;
00543         //          Indexed     -- Extended colours have no 'Indexed' form
00544 } ColourDefn;
00545 #endif      // if FALSE
00546 
00547 
00548 
00549 #endif      // INC_COLMODEL
00550 

Generated on Sat Nov 10 03:44:52 2007 for Camelot by  doxygen 1.4.4