TranspGradTable Class Reference

A kernel representation of a transparent graduation table. More...

#include <gradtbl.h>

Inheritance diagram for TranspGradTable:

CCObject SimpleCCObject List of all members.

Public Member Functions

 TranspGradTable (BOOL LargeTable=FALSE)
 Default constructor for a GradTable.
 ~TranspGradTable ()
 Destructor for a TranspGradTable.
void SetTableSize (BOOL LargeTable)
 To set the size of this Grad table.
BOOL BuildTable (INT32 StartTransp, INT32 EndTransp)
 Builds a TransparentGradTable from StartTransp to EndTransp.
BOOL BuildTable (INT32 StartTransp, INT32 EndTransp, CProfileBiasGain &BiasGain)
 Builds a TransparentGradTable from StartTransp to EndTransp that reflects the supplied BiasGain values.
BOOL BuildTable (INT32 StartTransp, INT32 EndTransp, TransparencyRamp *pTranspTable)
 Builds a TransparentGradTable from StartTransp to EndTransp with inbetween transparency levels held in pTranspTable.
BOOL BuildHighQualityRepeatTable (INT32 StartTransp, INT32 EndTransp, CProfileBiasGain &BiasGain)
 Builds a high quality repeating TransparentGradTable from StartTransp to EndTransp that reflects the supplied BiasGain values.
BOOL BuildHighQualityRepeatTable (INT32 StartTransp, INT32 EndTransp, TransparencyRamp *pTranspTable)
 Builds a high quality repeating TransparentGradTable from StartTransp to EndTransp.
BOOL BuildBitmapTable (INT32 StartTransp, INT32 EndTransp, CProfileBiasGain &BiasGain)
 Builds a TransparentGradTable from StartTransp to EndTransp This function forces the table to be 256 entries (for bitmap transparency) The function now (also) takes into account the applied transparency profile.
BOOL BuildBitmapTable (INT32 StartTransp, INT32 EndTransp, TransparencyRamp *pTranspTable, CProfileBiasGain &BiasGain)
 Builds a TransparentGradTable from StartTransp to EndTransp This function forces the table to be 256 entries (for bitmap transparency) The function now (also) takes into account the applied transparency profile.
TransparentGradTableGetTable (void) const
BOOL IsLarge (void) const

Protected Member Functions

INT32 GetTableSize (GDrawContext *GD, BOOL LargeTable)
INT32 GetTableLength (GDrawContext *GD, BOOL LargeTable)

Private Member Functions

void FillSection (INT32 startindex, INT32 endindex, INT32 starttransp, INT32 endtransp)
 Builds a TransparentGradTable from StartTransp to EndTransp with inbetween transparency levels held in pTranspTable.

Private Attributes

BOOL m_bLargeTable
TransparentGradTablem_pTable

Detailed Description

A kernel representation of a transparent graduation table.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/9/94
See also:
-

Definition at line 223 of file gradtbl.h.


Constructor & Destructor Documentation

TranspGradTable::TranspGradTable BOOL  LargeTable = FALSE  ) 
 

Default constructor for a GradTable.

Author:
Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/10/96
Returns:
Errors: -

Definition at line 1028 of file gradtbl.cpp.

01029 {
01030     m_pTable = NULL;
01031     m_bLargeTable = LargeTable;
01032 }

TranspGradTable::~TranspGradTable  ) 
 

Destructor for a TranspGradTable.

Author:
Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/10/96

Definition at line 1044 of file gradtbl.cpp.

01045 {
01046     if (m_pTable != NULL)
01047     {
01048         CCFree(m_pTable);
01049         m_pTable = NULL;
01050     }
01051 }


Member Function Documentation

BOOL TranspGradTable::BuildBitmapTable INT32  StartTransp,
INT32  EndTransp,
TransparencyRamp pTranspTable,
CProfileBiasGain BiasGain
 

Builds a TransparentGradTable from StartTransp to EndTransp This function forces the table to be 256 entries (for bitmap transparency) The function now (also) takes into account the applied transparency profile.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> (modified by CGS)
Date:
12/3/97 (15/2/2000)
Parameters:
- [INPUTS]
Returns:
Errors: -

Definition at line 1507 of file gradtbl.cpp.

01508 {
01509     TranspRampItem *pTTI=NULL;
01510     if (pTranspTable!=NULL) 
01511         pTTI=pTranspTable->GetFirstTransp();
01512 
01513     if (pTTI==NULL)
01514     {
01515         return BuildBitmapTable(StartTransp, EndTransp, BiasGain);
01516     }
01517 
01518     if (m_pTable != NULL)
01519     {
01520         CCFree(m_pTable);
01521         m_pTable = NULL;
01522     }
01523 
01524     m_pTable = (TransparentGradTable*) CCMalloc(256);
01525     if (m_pTable == NULL)
01526         return(FALSE);
01527 
01528     INT32 ei, si=0;
01529     INT32 end, start = StartTransp;
01530     while (pTTI)
01531     {
01532         ei = (INT32)(pTTI->GetPosition()*255.0 + 0.5);
01533         end = pTTI->GetTransparency();
01534         FillSection(si,ei,start,end);
01535         si = ei;
01536         start = end;
01537         pTTI = pTranspTable->GetNextTransp(pTTI);
01538     }
01539     end = EndTransp;
01540     FillSection(si,255,start,end);
01541     
01542     return TRUE;
01543 }

BOOL TranspGradTable::BuildBitmapTable INT32  StartTransp,
INT32  EndTransp,
CProfileBiasGain BiasGain
 

Builds a TransparentGradTable from StartTransp to EndTransp This function forces the table to be 256 entries (for bitmap transparency) The function now (also) takes into account the applied transparency profile.

Author:
Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com> (modified by CGS)
Date:
24/10/96 (15/2/2000)
Parameters:
- [INPUTS]
Returns:
Errors: -

Definition at line 1421 of file gradtbl.cpp.

01422 {
01423     if (m_pTable != NULL)
01424     {
01425         CCFree(m_pTable);
01426         m_pTable = NULL;
01427     }
01428 
01429     m_pTable = (TransparentGradTable*) CCMalloc(256);
01430 
01431     if (m_pTable == NULL)
01432         return(FALSE);
01433 
01434     const INT32 Length = 0x100;
01435     DWORD Index;
01436 
01437     CProfileBiasGain DefaultBiasGain;
01438 
01439     // make some optimisation decisions ....
01440 
01441     if (!(BiasGain == DefaultBiasGain))
01442     {
01443         double MixFraction;
01444         double temp;
01445         double RLength = 1.0/Length;
01446         
01447         BiasGain.SetIntervals (AFp (0), AFp (0x100));
01448         
01449         for (Index= 0; Index < 0x100; Index++)
01450         {
01451             MixFraction = BiasGain.MapInterval( AFp( Index ) );
01452             MixFraction *= RLength;
01453             
01454             temp = StartTransp * (1-MixFraction);
01455             temp += (EndTransp * MixFraction);
01456 
01457             m_pTable->Table[Index] = static_cast<BYTE> ( temp );
01458         }
01459         
01460         if (BiasGain.GetIsAFeatherProfile ())
01461         {
01462             // were a feather profile - we need to do a bit of extra work to ensure that ilans
01463             // feather renders correctly.  We MUST ensure that ilans white part of the bitmap
01464             // is rendered as 100% transparent.  The following lines of code do this ....
01465 
01466             // TODO: (Gavin) Why on earth is this setting Index-2 and Index-1 to 255
01467             // when the code below overwrites Index-2 anyway?
01468             m_pTable->Table[Index-2] = static_cast<BYTE> ( 255 );
01469             m_pTable->Table[Index-1] = static_cast<BYTE> ( 255 );
01470         }
01471     }
01472     else
01473     {
01474         INT32 Transp = (StartTransp << 24) + 0x00800000;
01475         INT32 TranspStep = (EndTransp - StartTransp) * 0x010101;
01476         BYTE *pTransp = &(m_pTable->Table[0]);
01477         
01478         for (Index= 0; Index < 0x100; Index++)
01479         {
01480             pTransp[Index] = (BYTE)((Transp >> 24) & 0xFF);
01481             Transp += TranspStep;
01482         }
01483     }
01484 
01485     // TODO: (Gavin) Why on earth is this setting 0xFE and not 0xFF?
01486     m_pTable->Table[0xFE] = static_cast <BYTE> ( EndTransp );
01487     
01488     return(TRUE);
01489 }

BOOL TranspGradTable::BuildHighQualityRepeatTable INT32  StartTransp,
INT32  EndTransp,
TransparencyRamp pTranspTable
 

Builds a high quality repeating TransparentGradTable from StartTransp to EndTransp.

Author:
Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/7/2000
Parameters:
StartTransp = the current start transparency level [INPUTS] EndTransp = the current end transparency level pTranspTable = the ramp to build for
Returns:
Errors: -

Definition at line 1370 of file gradtbl.cpp.

01371 {
01372     if (!pTranspTable)
01373     {
01374         SetTableSize(TRUE);
01375 
01376         if (m_pTable == NULL)
01377             return FALSE;
01378 
01379         GDrawContext *pContext = GRenderRegion::GetStaticDrawContext();
01380 
01381         INT32 TableLength = GetTableSize (pContext, IsLarge ());
01382         
01383         double MixFraction = 0.0;
01384         double MixStep = 2.0/TableLength;
01385         double temp;
01386 
01387         for (INT32 Index = 0; (Index<<1) < TableLength; Index++)
01388         {
01389             //MixFraction = BiasGain.MapInterval( AFp( Index ) );
01390             //MixFraction /= Length;
01391             temp = StartTransp * (1-MixFraction);
01392             temp += (EndTransp * MixFraction);
01393             m_pTable->Table[Index] =
01394             m_pTable->Table[TableLength-Index-1] = static_cast<BYTE> ( temp );
01395             
01396             MixFraction += MixStep;
01397         }
01398     }
01399     else
01400     {
01401         ERROR3 ("Attempt to build a multi-stage transparent fill - NOT fully implemented yet!");
01402     }
01403     
01404     return TRUE;
01405 }

BOOL TranspGradTable::BuildHighQualityRepeatTable INT32  StartTransp,
INT32  EndTransp,
CProfileBiasGain BiasGain
 

Builds a high quality repeating TransparentGradTable from StartTransp to EndTransp that reflects the supplied BiasGain values.

Author:
Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/7/2000
Parameters:
StartTransp = the current start transparency level [INPUTS] EndTransp = the current end transparency level BiasGain = the profile to build for
Returns:
Errors: -

Definition at line 1304 of file gradtbl.cpp.

01305 {
01306     SetTableSize(TRUE);
01307 
01308     if (m_pTable == NULL)
01309     {
01310         return FALSE;
01311     }
01312 
01313     GDrawContext *pContext = GRenderRegion::GetStaticDrawContext();
01314 
01315     INT32 TableLength = GetTableLength (pContext, IsLarge ());
01316     INT32 halfTableLength = TableLength/2;
01317         
01318     double MixFraction = 0.0;
01319     double temp;
01320     double res;
01321     INT32 Index;
01322 
01323     BOOL secondHalf = FALSE;
01324     INT32 secondHalfVal =0;
01325 
01326     BiasGain.SetIntervals (AFp (0), AFp (halfTableLength));
01327 
01328     for (Index = 0; Index < TableLength; Index++)
01329     {
01330         if (!secondHalf)
01331         {
01332             res = BiasGain.MapInterval( AFp( Index) );
01333         }
01334         else
01335         {
01336             res = BiasGain.MapInterval( AFp( secondHalfVal) );
01337         }
01338 
01339         MixFraction = res / (halfTableLength);
01340         temp = StartTransp * (1-MixFraction);
01341         temp += (EndTransp * MixFraction);
01342         m_pTable->Table[Index] = static_cast<BYTE> ( temp );
01343             
01344         if (!(Index < halfTableLength))
01345         {
01346             secondHalfVal = TableLength - Index;
01347             secondHalf = TRUE;
01348         }
01349     }
01350 
01351     return (TRUE);
01352 }

BOOL TranspGradTable::BuildTable INT32  StartTransp,
INT32  EndTransp,
TransparencyRamp pTranspTable
 

Builds a TransparentGradTable from StartTransp to EndTransp with inbetween transparency levels held in pTranspTable.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/3/97
Parameters:
StartTransp = the current start transparency level [INPUTS] EndTransp = the current end transparency level pTranspTable = all the inbetween transparency table levels.
Returns:
Errors: -

Definition at line 1251 of file gradtbl.cpp.

01252 {
01253     TranspRampItem *pTTI=NULL;
01254     if (pTranspTable!=NULL) 
01255         pTTI=pTranspTable->GetFirstTransp();
01256 
01257     if (pTTI==NULL)
01258         return BuildTable(StartTransp,EndTransp);
01259 
01260     SetTableSize(m_bLargeTable);
01261 
01262     if (m_pTable == NULL)
01263         return FALSE;
01264 
01265     INT32 ei, si=0;
01266     INT32 end, start=StartTransp;
01267     
01268     GDrawContext *pContext = GRenderRegion::GetStaticDrawContext();
01269     const INT32 Length = GetTableLength(pContext, IsLarge());
01270 
01271     while (pTTI)
01272     {
01273         ei = (INT32)((pTTI->GetPosition() * (Length-1)) + 0.5);
01274         end = pTTI->GetTransparency();
01275         FillSection(si,ei,start,end);
01276         si = ei;
01277         start = end;
01278         pTTI = pTranspTable->GetNextTransp(pTTI);
01279     }
01280     ei  = Length-1;
01281     end = EndTransp;
01282     FillSection(si,ei,start,end);
01283 
01284     return TRUE;
01285 }

BOOL TranspGradTable::BuildTable INT32  StartTransp,
INT32  EndTransp,
CProfileBiasGain BiasGain
 

Builds a TransparentGradTable from StartTransp to EndTransp that reflects the supplied BiasGain values.

Author:
Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/2/2000
Parameters:
- [INPUTS]
Returns:
Errors: -

Definition at line 1206 of file gradtbl.cpp.

01207 {
01208     SetTableSize(FALSE);
01209 
01210     if (m_pTable == NULL)
01211         return(FALSE);
01212 
01213     GDrawContext *pContext = GRenderRegion::GetStaticDrawContext();
01214 
01215     const INT32 Length = GetTableLength(pContext, FALSE);
01216     const double RLength = 1.0/Length;
01217     BiasGain.SetIntervals (AFp (0), AFp (Length));
01218 
01219     double MixFraction;
01220     double temp;
01221     INT32 Index;
01222 
01223     for (Index = 0; Index < Length; Index++)
01224     {
01225         MixFraction = BiasGain.MapInterval( AFp( Index ) );
01226         MixFraction *= RLength;
01227         temp = StartTransp * (1-MixFraction);
01228         temp += (EndTransp * MixFraction);
01229         m_pTable->Table[Index] = static_cast<BYTE> ( temp );
01230     }
01231 
01232     return(TRUE);
01233 }

BOOL TranspGradTable::BuildTable INT32  StartTransp,
INT32  EndTransp
 

Builds a TransparentGradTable from StartTransp to EndTransp.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/9/94
Parameters:
- [INPUTS]
Returns:
Errors: -

Definition at line 1157 of file gradtbl.cpp.

01158 {
01159     SetTableSize(m_bLargeTable);
01160 
01161     if (m_pTable == NULL)
01162         return(FALSE);
01163 
01164     GDrawContext *pContext = GRenderRegion::GetStaticDrawContext();
01165 
01166     // If we are a large table then build it ourself
01167     if (IsLarge())
01168     {
01169         const INT32 Length = GetTableLength(pContext, IsLarge());
01170 
01171         const INT32 TranspIncrement = ((EndTransp - StartTransp) << 24) / Length;
01172 
01173         INT32 Transp = StartTransp;
01174         INT32 Index;
01175 
01176         for (Index = 0; Index < Length; Index++)
01177         {
01178             m_pTable->Table[Index] = (Transp >> 24) & 0xFF;
01179             Transp += TranspIncrement;
01180         }
01181 
01182         return(TRUE);
01183     }
01184     else
01185     {
01186         // Otherwise get a GDrawContext to build it
01187         return(pContext->BuildTransparencyTable(StartTransp, EndTransp, m_pTable));
01188     }
01189 }

void TranspGradTable::FillSection INT32  startindex,
INT32  endindex,
INT32  starttransp,
INT32  endtransp
[private]
 

Builds a TransparentGradTable from StartTransp to EndTransp with inbetween transparency levels held in pTranspTable.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/9/94
Parameters:
StartIndex,EndIndex = range of indexes to fill [INPUTS] starttransp endtransp
Returns:
Errors: -

Definition at line 1562 of file gradtbl.cpp.

01563 {
01564     INT32 den = endindex-startindex;
01565     if (den<0)
01566         return;
01567 
01568     if (den==0)
01569     {
01570         m_pTable->Table[endindex] = (UINT32)endtransp;
01571     }
01572     else
01573     {
01574         INT32 t = (starttransp<<22) + 0x00200000;
01575         INT32 inc = ((endtransp-starttransp)<<22) / den;
01576         for (INT32 i=startindex; i<=endindex; i++)
01577         {
01578             m_pTable->Table[i] = (t>>22) & 0xFF;
01579             t+=inc;
01580         }
01581     }
01582 }

TransparentGradTable* TranspGradTable::GetTable void   )  const [inline]
 

Definition at line 243 of file gradtbl.h.

00243 { return(m_pTable); };

INT32 TranspGradTable::GetTableLength GDrawContext GD,
BOOL  LargeTable
[protected]
 

Author:
Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/10/96
Parameters:
GD - pointer to GDraw context to use [INPUTS] LargeTable - if true then use a long grad table
Returns:
The number of entries in a grad table for the specified context

Definition at line 1091 of file gradtbl.cpp.

01092 {
01093     if (LargeTable)
01094     {
01095         return(GD->GetLongTransparentGraduationTableLength());
01096     }
01097     else
01098     {
01099         return(GD->GetTransparentGraduationTableLength());
01100     }
01101 }

INT32 TranspGradTable::GetTableSize GDrawContext GD,
BOOL  LargeTable
[protected]
 

Author:
Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/10/96
Parameters:
GD - pointer to GDraw context to use [INPUTS] LargeTable - if true then use a long grad table
Returns:
The size in bytes of a grad table for the specified context

Definition at line 1066 of file gradtbl.cpp.

01067 {
01068     if (LargeTable)
01069     {
01070         return(GD->GetLongTransparentGraduationTableSize());
01071     }
01072     else
01073     {
01074         return(GD->GetTransparentGraduationTableSize());
01075     }
01076 }

BOOL TranspGradTable::IsLarge void   )  const [inline]
 

Definition at line 244 of file gradtbl.h.

00244 { return(m_bLargeTable); };

void TranspGradTable::SetTableSize BOOL  LargeTable  ) 
 

To set the size of this Grad table.

Author:
Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/10/96
Parameters:
LargeTable - if true then use a long grad table [INPUTS]
Notes: The table defaults to small

Definition at line 1119 of file gradtbl.cpp.

01120 {
01121     // If we don't have the right table size or no table at all
01122     if ((LargeTable != m_bLargeTable) || (m_pTable == NULL))
01123     {
01124         m_bLargeTable = LargeTable;
01125 
01126         if (m_pTable != NULL)
01127         {
01128             CCFree(m_pTable);
01129             m_pTable = NULL;
01130         }
01131 
01132         GDrawContext *GD = GRenderRegion::GetStaticDrawContext();
01133 
01134         if (GD != NULL)
01135         {
01136             INT32 Size = GetTableSize(GD, m_bLargeTable);
01137             
01138             m_pTable = (TransparentGradTable*) CCMalloc(Size);
01139         }
01140     }
01141 }


Member Data Documentation

BOOL TranspGradTable::m_bLargeTable [private]
 

Definition at line 257 of file gradtbl.h.

TransparentGradTable* TranspGradTable::m_pTable [private]
 

Definition at line 258 of file gradtbl.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 04:02:20 2007 for Camelot by  doxygen 1.4.4