diff options
author | Babak Mahbod <bmahbod@openoffice.org> | 2001-02-07 23:12:20 +0000 |
---|---|---|
committer | Babak Mahbod <bmahbod@openoffice.org> | 2001-02-07 23:12:20 +0000 |
commit | f6024fa9992ca19b1a63f69903e025a1a6b7bb07 (patch) | |
tree | c58a403a9f6b6f763ca740c4a289a789e2654277 /vcl/aqua/source/gdi/salgdi.cxx | |
parent | 3c838bdf8bb9d43b0a708390ea0de0e9ae0c3221 (diff) |
Salbmp now displays 8-bit palette.
Salvd disposes of GWorlds.
Salgdi disposes of GWorlds.
Salgdi rebuilts the ITable if necessary.
Header file now contains more constants.
Diffstat (limited to 'vcl/aqua/source/gdi/salgdi.cxx')
-rw-r--r-- | vcl/aqua/source/gdi/salgdi.cxx | 79 |
1 files changed, 60 insertions, 19 deletions
diff --git a/vcl/aqua/source/gdi/salgdi.cxx b/vcl/aqua/source/gdi/salgdi.cxx index 914aa8e90ad8..ed45fb5b63ad 100644 --- a/vcl/aqua/source/gdi/salgdi.cxx +++ b/vcl/aqua/source/gdi/salgdi.cxx @@ -2,8 +2,8 @@ * * $RCSfile: salgdi.cxx,v $ * - * $Revision: 1.48 $ - * last change: $Author: bmahbod $ $Date: 2001-01-31 23:56:13 $ + * $Revision: 1.49 $ + * last change: $Author: bmahbod $ $Date: 2001-02-08 00:12:20 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -96,8 +96,7 @@ static inline unsigned long AbsoluteValue ( const long nValue ) return nAbsValue; } // AbsoluteValue - -// ======================================================================= +// ----------------------------------------------------------------------- static inline BOOL Boolean2BOOL ( const Boolean bBooleanValue ) { @@ -115,7 +114,6 @@ static inline BOOL Boolean2BOOL ( const Boolean bBooleanValue ) return nBOOLValue; } // AbsoluteValue - // ======================================================================= // ======================================================================= @@ -401,8 +399,8 @@ static unsigned long RGBDistance ( const RGBColor *pRGBColor1, nDeltaBlue = (long)pRGBColor2->blue - (long)pRGBColor1->blue; nRGBDist = AbsoluteValue(nDeltaRed) - + AbsoluteValue(nDeltaGreen) - + AbsoluteValue(nDeltaBlue); + + AbsoluteValue(nDeltaGreen) + + AbsoluteValue(nDeltaBlue); return nRGBDist; } // RGBDistance @@ -452,7 +450,7 @@ static void GetBestSalColor ( const CTabPtr pCTable, if ( bRGBColorsMatch == TRUE ) { - *pBestSalColor= nCTableIndex; + *pBestSalColor = nCTableIndex; } // if else { @@ -471,22 +469,65 @@ static void GetBestSalColor ( const CTabPtr pCTable, // ----------------------------------------------------------------------- -static void GetCTableIndex ( const PixMapPtr pPixMap, - const RGBColor *pRGBColor, +static void GetCTableIndex ( const RGBColor *pRGBColor, SalColor *rSalColor ) { - CTabPtr pCTable = NULL; + GDPtr pGDevice = NULL; - pCTable = *(*pPixMap).pmTable; + pGDevice = *GetGDevice(); - if ( pCTable != NULL ) + if ( pGDevice != NULL ) { - GetBestSalColor( pCTable, pRGBColor, rSalColor ); + PixMapPtr pPixMap = *pGDevice->gdPMap; - if ( *rSalColor > pCTable->ctSize ) + if ( pPixMap != NULL ) { - *rSalColor = 255; + CTabPtr pCTable = *pPixMap->pmTable; + + if ( pCTable != NULL ) + { + ITabPtr pITable = *pGDevice->gdITable; + + if ( pITable != NULL ) + { + // Is the inverse color table up-to-date? + + if ( pITable->iTabSeed != pCTable->ctSeed ) + { + // Update our inverse color table + + MakeITable( pPixMap->pmTable, + pGDevice->gdITable, + pGDevice->gdResPref + ); + + pGDevice = *GetGDevice(); + pITable = *pGDevice->gdITable; + pPixMap = *pGDevice->gdPMap; + pCTable = *pPixMap->pmTable; + } // if + } // if + + // Now we proceed to find the closest match in our + // color table using a basic 2-norm. Note that, + // here we shall utilize a psuedo Euclidean norm. + // Where as in a standard Euclidean norm one sums up + // the square of the RGB color distances before + // proceeding to take the square root, in our case, + // we only measure the RGB color difference before + // summing up the totals. + + if ( pCTable != NULL ) + { + GetBestSalColor( pCTable, pRGBColor, rSalColor ); + + if ( *rSalColor > pCTable->ctSize ) + { + *rSalColor = 255; + } // if + } // if + } // if } // if } // if } // GetCTableIndex @@ -502,7 +543,7 @@ static SalColor RGBColor2SALColor ( const RGBColor *pRGBColor ) GDPtr pGDevice = NULL; SalColor nSalColor = 0; - pGDevice = *GetGDevice ( ); + pGDevice = *GetGDevice( ); if ( pGDevice != NULL ) { @@ -518,7 +559,7 @@ static SalColor RGBColor2SALColor ( const RGBColor *pRGBColor ) } // if else { - GetCTableIndex( pPixMap, pRGBColor, &nSalColor ); + GetCTableIndex( pRGBColor, &nSalColor ); } // else } // if } // if @@ -1081,7 +1122,7 @@ SalGraphics::~SalGraphics() if ( maGraphicsData.mpCGrafPort != NULL ) { - DisposePort( maGraphicsData.mpCGrafPort ); + DisposeGWorld( maGraphicsData.mpCGrafPort ); maGraphicsData.mpCGrafPort = NULL; } // if |