00001 // $Id: gradtbl.h 1282 2006-06-09 09:46: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 00099 // Classes to implement the graduation tables required for special path filling attributes 00100 00101 #ifndef INC_GRADTBL 00102 #define INC_GRADTBL 00103 00104 //#include "gconsts.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00105 //#include "gradtype.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00106 //#include "colmodel.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00107 //#include "biasgain.h" // for CProfileBiasGain (i.e. profiled fills/transparency!) - in camtypes.h [AUTOMATICALLY REMOVED] 00108 00109 class DocColour; 00110 class ColourContext; 00111 class View; 00112 class ColourRamp; 00113 class TransparencyRamp; 00114 00115 /******************************************************************************************** 00116 00117 > class GradTable: public CCObject 00118 00119 Author: Will_Cowling (Xara Group Ltd) <camelotdev@xara.com> 00120 Created: 14/9/94 00121 Purpose: A kernel representation of a graduation table. 00122 (This is a table of 8-bpp dither pattern specifiers for GDraw) 00123 00124 SeeAlso: GradTable32 00125 00126 Notes: There are now 3 base functions in GradTable and GradTable32 which build 00127 graduation tables. The tables are actually identical in meaning, but are 00128 encoded as: 00129 (a) Gavin 8bpp dither patterns, 00130 (b) RGBQUAD RGB structures, 00131 (c) COLORREF RGB values 00132 this is because the different places that use these tables demand the 00133 different formats, and converting all the code to use only one table 00134 format is non-trivial and/or inefficient. 00135 00136 ********************************************************************************************/ 00137 00138 class GradTable: public CCObject 00139 { 00140 CC_DECLARE_DYNCREATE(GradTable) 00141 00142 public: 00143 GradTable(BOOL LargeTable = FALSE); 00144 ~GradTable(); 00145 00146 void SetTableSize(BOOL LargeTable); 00147 // Set the overall size of the table 00148 00149 INT32 GetTableLength(void) { return(m_pTable->Length); }; 00150 00151 BOOL BuildTable(DocColour &StartCol, DocColour &EndCol, 00152 View *ContextView, EFFECTTYPE Effect, 00153 BOOL LargeTable = FALSE); 00154 // Set table size, and build a single-stage gradfill in it 00155 00156 BOOL BuildTable(DocColour &StartCol, DocColour &EndCol, 00157 View *ContextView, EFFECTTYPE Effect, 00158 CProfileBiasGain& BiasGain, BOOL LargeTable = FALSE); 00159 // Set table size, and build a single-stage gradfill in it 00160 // This version takes into account the new profile stuff (CGS - 4/2/2000) 00161 00162 BOOL BuildTable(DocColour &StartCol, DocColour &EndCol, ColourRamp *pColourRamp, 00163 View *ContextView, EFFECTTYPE Effect, 00164 BOOL LargeTable = FALSE); 00165 // Set table size, and build a multi-stage gradfill in it 00166 00167 BOOL BuildHighQualityRepeatTable(DocColour &StartCol, DocColour &EndCol, ColourRamp *pColourRamp, 00168 View *ContextView, EFFECTTYPE Effect); 00169 // Set table size, and build a multi-stage gradfill in it 00170 // This version build a high quality (aliasing free) repeating fill table. 00171 // This version handles fills with colour ramps, and those without 00172 00173 BOOL BuildHighQualityRepeatTable(DocColour &StartCol, DocColour &EndCol, 00174 View *ContextView, EFFECTTYPE Effect, 00175 CProfileBiasGain& BiasGain); 00176 // Set table size, and build a multi-stage gradfill in it 00177 // This version build a high quality (aliasing free) repeating fill table. 00178 // This version handles profiled fills 00179 00180 BOOL BuildTable(DocColour &StartCol, DocColour &EndCol, 00181 View *ContextView, EFFECTTYPE Effect, 00182 DWORD FirstEntry, DWORD LastEntry); 00183 // Build graduations between StartCol and EndCol, filling the given 00184 // portion of the table - used for one stage of a multi-stage fill 00185 00186 BOOL AddToTable(DocColour &NewCol, View *ContextView, DWORD Index); 00187 // Adds the given colour as entry 'Index' in the table 00188 00189 GraduationTable *GetTable(void) { return(m_pTable); }; 00190 // Proper access function for finding our Table data member 00191 00192 BOOL IsLarge(void) { return(m_bLargeTable); }; 00193 00194 protected: 00195 void FillTable(DWORD StartIndex, DWORD EndIndex, 00196 PColourRGBT *StartDef, PColourRGBT *EndDef); 00197 // Internal helper function for linearly interpolating between 2 RGB values 00198 00199 INT32 GetTableSize(GDrawContext* GD, BOOL LargeTable); 00200 // Returns the size (bytes) of the structure required 00201 00202 INT32 GetTableLength(GDrawContext* GD, BOOL LargeTable); 00203 // Returns the size (entries) of the structure required 00204 00205 private: 00206 BOOL m_bLargeTable; 00207 GraduationTable* m_pTable; 00208 }; 00209 00210 00211 00212 /******************************************************************************************** 00213 00214 > class TranspGradTable: public CCObject 00215 00216 Author: Will_Cowling (Xara Group Ltd) <camelotdev@xara.com> 00217 Created: 14/9/94 00218 Purpose: A kernel representation of a transparent graduation table. 00219 SeeAlso: - 00220 00221 ********************************************************************************************/ 00222 00223 class TranspGradTable: public CCObject 00224 { 00225 CC_DECLARE_DYNCREATE(TranspGradTable) 00226 00227 public: 00228 TranspGradTable(BOOL LargeTable = FALSE); 00229 ~TranspGradTable(); 00230 00231 00232 void SetTableSize(BOOL LargeTable); 00233 // Set the overall size of the table 00234 00235 BOOL BuildTable(INT32 StartTransp, INT32 EndTransp); 00236 BOOL BuildTable(INT32 StartTransp, INT32 EndTransp, CProfileBiasGain& BiasGain); 00237 BOOL BuildTable(INT32 StartTransp, INT32 EndTransp, TransparencyRamp *pTranspTable); 00238 BOOL BuildHighQualityRepeatTable(INT32 StartTransp, INT32 EndTransp, CProfileBiasGain& BiasGain); 00239 BOOL BuildHighQualityRepeatTable(INT32 StartTransp, INT32 EndTransp, TransparencyRamp *pTranspTable); 00240 BOOL BuildBitmapTable(INT32 StartTransp, INT32 EndTransp, CProfileBiasGain& BiasGain); 00241 BOOL BuildBitmapTable(INT32 StartTransp, INT32 EndTransp, TransparencyRamp *pTranspTable, CProfileBiasGain& BiasGain); 00242 00243 TransparentGradTable* GetTable(void) const { return(m_pTable); }; 00244 BOOL IsLarge(void) const { return(m_bLargeTable); }; 00245 00246 protected: 00247 INT32 GetTableSize(GDrawContext* GD, BOOL LargeTable); 00248 // Returns the size (bytes) of the structure required 00249 00250 INT32 GetTableLength(GDrawContext* GD, BOOL LargeTable); 00251 // Returns the size (entries) of the structure required 00252 00253 private: 00254 void FillSection(INT32 startindex, INT32 endindex, INT32 starttransp, INT32 endtransp); 00255 00256 private: 00257 BOOL m_bLargeTable; 00258 TransparentGradTable* m_pTable; 00259 }; 00260 00261 00262 00263 /******************************************************************************************** 00264 00265 > class GradTable32: public CCObject 00266 00267 Author: Will_Cowling (Xara Group Ltd) <camelotdev@xara.com> 00268 Created: 14/9/94 00269 Purpose: A kernel representation of a 32 bpp graduation table. 00270 (This is a table of COLORREF RGB values for GDraw) 00271 00272 SeeAlso: GradTable 00273 00274 Notes: There are now 3 base functions in GradTable and GradTable32 which build 00275 graduation tables. The tables are actually identical in meaning, but are 00276 encoded as: 00277 (a) Gavin 8bpp dither patterns, 00278 (b) RGBQUAD RGB structures, 00279 (c) COLORREF RGB values 00280 this is because the different places that use these tables demand the 00281 different formats, and converting all the code to use only one table 00282 format is non-trivial and/or inefficient. 00283 00284 ********************************************************************************************/ 00285 00286 class GradTable32: public CCObject 00287 { 00288 CC_DECLARE_DYNCREATE(GradTable32) 00289 00290 public: 00291 GradTable32(); 00292 ~GradTable32(); 00293 00294 00295 public: // GradTable32 sepcific methods 00296 void SetTableSize(BOOL LargeTable); 00297 // Set the overall size of the table 00298 00299 BOOL BuildTable(DocColour &StartCol, DocColour &EndCol, 00300 View *ContextView, EFFECTTYPE Effect, 00301 DWORD TableSize = 0x100); 00302 // Set table size, and build a single-stage gradfill in it 00303 00304 BOOL BuildTable(DocColour &StartCol, DocColour &EndCol, 00305 View *ContextView, EFFECTTYPE Effect, 00306 DWORD FirstEntry, DWORD LastEntry); 00307 // Build graduations between StartCol and EndCol, filling the given 00308 // portion of the table - used for one stage of a multi-stage fill 00309 00310 public: // Generic graduation-building methods - produce tables of RGB values 00311 // These are used internally to build the GradTable32, but are also exported 00312 // for GRenderRegion, OSRenderRegion, OILBitmap, etc for generating 00313 // fill/contone tables with. 00314 static BOOL BuildGraduatedPalette(DocColour &StartCol, DocColour &EndCol, 00315 View *ContextView, EFFECTTYPE Effect, 00316 DWORD TableSize, COLORREF *pTable); 00317 // Builds a table of graduated RGBQUADs between StartCol and EndCol 00318 00319 static BOOL BuildGraduatedPalette(DocColour &StartCol, DocColour &EndCol, 00320 View *ContextView, EFFECTTYPE Effect, 00321 DWORD FirstEntry, DWORD LastEntry, 00322 COLORREF *pTable); 00323 // Builds a portion of a table of graduated RGBQUADs between StartCol and EndCol 00324 00325 static BOOL BuildGraduatedPalette(DocColour &StartCol, DocColour &EndCol, 00326 View *ContextView, EFFECTTYPE Effect, 00327 DWORD TableSize, RGBQUAD *pTable); 00328 // Builds a table of graduated RGBQUADs between StartCol and EndCol 00329 00330 static BOOL BuildGraduatedPalette(DocColour &StartCol, DocColour &EndCol, // CGS 00331 View *ContextView, EFFECTTYPE Effect, 00332 DWORD TableSize, RGBQUAD *pTable, 00333 CProfileBiasGain& BiasGain); 00334 // Builds a portion of a table of graduated RGBQUADs between StartCol and EndCol 00335 00336 static BOOL BuildGraduatedPalette(DocColour &StartCol, DocColour &EndCol, 00337 View *ContextView, EFFECTTYPE Effect, 00338 DWORD FirstEntry, DWORD LastEntry, 00339 RGBQUAD *pTable); 00340 // Builds a portion of a table of graduated RGBQUADs between StartCol and EndCol 00341 00342 protected: 00343 static BOOL BuildPaletteInternal(DocColour &StartCol, DocColour &EndCol, 00344 View *ContextView, EFFECTTYPE Effect, 00345 DWORD FirstEntry, DWORD LastEntry, 00346 void *pTable, BOOL IsColorRef, CProfileBiasGain& BiasGain); // CGS 00347 // Internal function called by all of the above variants 00348 00349 // --- 00350 static BOOL BuildPaletteInternalRGB(DocColour &StartCol, DocColour &EndCol, View *ContextView, 00351 DWORD FirstEntry, DWORD LastEntry, 00352 void *pTable, BOOL IsColorRef, CProfileBiasGain& BiasGain); // CGS 00353 // Internal helper function for optimised RGB Mix GradTable32 generation 00354 00355 static BOOL BuildPaletteInternalHSV(DocColour &StartCol, DocColour &EndCol, 00356 View *ContextView, EFFECTTYPE Effect, 00357 DWORD FirstEntry, DWORD LastEntry, 00358 void *pTable, BOOL IsColorRef,CProfileBiasGain& BiasGain); // CGS 00359 // Internal helper function for optimised HSV Mix GradTable32 generation 00360 00361 // --- 00362 static BOOL BuildPaletteInternalRGBComposite(DocColour &StartCol, DocColour &EndCol, View *ContextView, 00363 DWORD FirstEntry, DWORD LastEntry, 00364 void *pTable, BOOL IsColorRef); 00365 // Internal helper function for optimised RGB Mix GradTable32 generation 00366 00367 }; 00368 00369 #endif // INC_GRADTBL 00370