summaryrefslogtreecommitdiff
path: root/vcl/aqua/source
diff options
context:
space:
mode:
authorBabak Mahbod <bmahbod@openoffice.org>2001-02-07 23:12:20 +0000
committerBabak Mahbod <bmahbod@openoffice.org>2001-02-07 23:12:20 +0000
commitf6024fa9992ca19b1a63f69903e025a1a6b7bb07 (patch)
treec58a403a9f6b6f763ca740c4a289a789e2654277 /vcl/aqua/source
parent3c838bdf8bb9d43b0a708390ea0de0e9ae0c3221 (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')
-rw-r--r--vcl/aqua/source/gdi/salbmp.cxx472
-rw-r--r--vcl/aqua/source/gdi/salgdi.cxx79
-rw-r--r--vcl/aqua/source/gdi/salvd.cxx8
3 files changed, 300 insertions, 259 deletions
diff --git a/vcl/aqua/source/gdi/salbmp.cxx b/vcl/aqua/source/gdi/salbmp.cxx
index cb0b7f6669ec..c8dfffca2ffa 100644
--- a/vcl/aqua/source/gdi/salbmp.cxx
+++ b/vcl/aqua/source/gdi/salbmp.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: salbmp.cxx,v $
*
- * $Revision: 1.18 $
+ * $Revision: 1.19 $
*
- * last change: $Author: bmahbod $ $Date: 2001-02-02 04:47:42 $
+ * 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
@@ -77,112 +77,28 @@
#include <salvd.hxx>
#endif
-// =======================================================================
-
-enum RGBColorType
- {
- eRedColor = 0,
- eGreenColor = 1,
- eBlueColor = 2
- };
-
-typedef RGBColorType RGBColorType;
-
-// =======================================================================
-
-// =======================================================================
+// ==================================================================
-static BYTE GetBestColorIndex ( const CTabHandle hCTable,
- const ColorSpecPtr pColorSpec,
- const RGBColorType eRGBColorType
- )
+static inline short GetMinColorCount( const short nPixMapColorDepth,
+ const BitmapPalette& rBitmapPalette
+ )
{
- BYTE nBestColor = 0;
- short nCTableSize = 0;
- short nCTableIndex = 0;
- short nBestCTableIndex = 0;
- unsigned short nNewDistance = 0;
- unsigned short nMinDistance = USHRT_MAX;
- BOOL bColorsMatch = FALSE;
- RGBColor aFirstColor = pColorSpec->rgb;
- RGBColor aNextColor;
-
- nCTableSize = (**hCTable).ctSize;
-
- while ( ( nCTableIndex < nCTableSize ) && ( bColorsMatch == FALSE ) )
- {
- aNextColor = (**hCTable).ctTable[nCTableIndex].rgb;
-
- switch( eRGBColorType )
- {
- case eRedColor:
- if ( aNextColor.red == aFirstColor.red )
- {
- bColorsMatch = TRUE;
- }
- break;
- case eGreenColor:
- if ( aNextColor.green == aFirstColor.green )
- {
- bColorsMatch = TRUE;
- }
- break;
- case eBlueColor:
- if ( aNextColor.blue == aFirstColor.blue )
- {
- bColorsMatch = TRUE;
- }
- break;
- } // switch
-
- if ( bColorsMatch == TRUE )
- {
- nBestCTableIndex = nCTableIndex;
- } // if
- else
- {
- long nDeltaColor = 0;
-
- switch( eRGBColorType )
- {
- case eRedColor:
- nDeltaColor = (long)aFirstColor.red - (long)aNextColor.red;
- break;
- case eGreenColor:
- nDeltaColor = (long)aFirstColor.green - (long)aNextColor.green;
- break;
- case eBlueColor:
- nDeltaColor = (long)aFirstColor.blue - (long)aNextColor.blue;
- break;
- } // switch
-
- if ( nDeltaColor < 0 )
- {
- nNewDistance = -nDeltaColor;
- } // if
- else
- {
- nNewDistance = nDeltaColor;
- } // else
-
- if ( nNewDistance < nMinDistance )
- {
- nMinDistance = nNewDistance;
- nBestCTableIndex = nCTableIndex;
- } // if
-
- nCTableIndex++;
- } //else
- } // while
-
- fprintf( stderr, "<INFO> best color table index = %hd\n", nBestCTableIndex );
+ short nBitmapPaletteCount = rBitmapPalette.GetEntryCount();
+ short nBitmapPaletteMinCount = 0;
- nBestColor = (BYTE)nBestCTableIndex;
+ if ( nPixMapColorDepth < nBitmapPaletteCount )
+ {
+ nBitmapPaletteMinCount = nPixMapColorDepth;
+ } // if
+ else
+ {
+ nBitmapPaletteMinCount = nBitmapPaletteCount;
+ } // else
- return nBestColor;
-} // GetBestColorIndex
+ return nBitmapPaletteMinCount;
+} // GetMinColorCount
-// =======================================================================
+// ==================================================================
// ==================================================================
@@ -438,27 +354,6 @@ static CTabHandle GetNewPixMapCTabCLUT( const short nPixMapBitDepth )
// ------------------------------------------------------------------
-static inline short GetMinColorCount( const short nPixMapColorDepth,
- const BitmapPalette& rBitmapPalette
- )
-{
- short nBitmapPaletteCount = rBitmapPalette.GetEntryCount();
- short nBitmapPaletteMinCount = 0;
-
- if ( nPixMapColorDepth < nBitmapPaletteCount )
- {
- nBitmapPaletteMinCount = nPixMapColorDepth;
- } // if
- else
- {
- nBitmapPaletteMinCount = nBitmapPaletteCount;
- } // else
-
- return nBitmapPaletteMinCount;
-} // GetMinColorCount
-
-// ------------------------------------------------------------------
-
static CTabHandle GetNewPixMapCTabBitmapPalette( const short nPixMapColorDepth,
const BitmapPalette &rBitmapPalette
)
@@ -765,8 +660,8 @@ static CTabHandle CopyPixMapCTabRGBDirect ( CTabHandle hPixMapCTab )
HLock( (Handle)hPixMapCTab );
hPixMapCTabCopy = (CTabHandle)NewHandleClear( sizeof( ColorTable )
- - sizeof( CSpecArray )
- );
+ - sizeof( CSpecArray )
+ );
if ( ( hPixMapCTabCopy != NULL ) && ( *hPixMapCTabCopy != NULL ) )
{
@@ -908,7 +803,7 @@ static PixMapHandle MallocPixMap ( const Size &rPixMapSize,
const SalGraphics *rSalGraphics
)
{
- PixMapHandle hNewPixMap = GetGWorldPixMap( rSalGraphics->maGraphicsData.mpGWorld );
+ PixMapHandle hNewPixMap = GetPortPixMap( rSalGraphics->maGraphicsData.mpCGrafPort );
if ( hNewPixMap == NULL )
{
@@ -979,8 +874,8 @@ BOOL SalBitmap::Create( const Size& rSize,
if ( pSVData != NULL )
{
- long nHeight = rSize.Height();
- long nWidth = rSize.Width();
+ const long nHeight = rSize.Height();
+ const long nWidth = rSize.Width();
Destroy();
@@ -1019,12 +914,12 @@ BOOL SalBitmap::Create( const Size& rSize,
bSalBitmapCreated = TRUE;
} // if
- } // if
- // Release the SalGraphics so that others can get a
- // handle to it in future GetGraphics() calls
+ // Release the SalGraphics so that others can get a
+ // handle to it in future GetGraphics() calls
- ReleaseGraphics( pGraphics );
+ ReleaseGraphics( pGraphics );
+ } // if
} // if
} // if
} // if
@@ -1045,26 +940,33 @@ BOOL SalBitmap::Create( const SalBitmap& rSalBmp,
SalGraphics* pGraphics
)
{
- USHORT nBitCount = 0;
+ USHORT nSalBmpBitCount = 0;
+ BOOL bSalBitmapCreated = FALSE;
if ( ( pGraphics != NULL )
&& ( pGraphics->maGraphicsData.mpCGrafPort != NULL )
)
{
- mhPixMap = GetPortPixMap( pGraphics->maGraphicsData.mpCGrafPort );
+ mhPixMap = MallocPixMap( rSalBmp.GetSize(),
+ rSalBmp.GetBitCount(),
+ BitmapPalette(),
+ pGraphics
+ );
- if ( mhPixMap != NULL )
+ if ( ( mhPixMap != NULL ) && ( *mhPixMap != NULL ) )
{
- nBitCount = GetPixDepth( mhPixMap );
+ nSalBmpBitCount = GetPixDepth( mhPixMap );
} // if
} // if
- if ( nBitCount == 0 )
+ if ( nSalBmpBitCount == 0 )
{
- nBitCount = rSalBmp.GetBitCount();
+ nSalBmpBitCount = rSalBmp.GetBitCount();
} // if
- return Create( rSalBmp, nBitCount );
+ bSalBitmapCreated = Create( rSalBmp, nSalBmpBitCount );
+
+ return bSalBitmapCreated;
} // SalBitmap::Create
// ------------------------------------------------------------------
@@ -1146,142 +1048,129 @@ BitmapBuffer* SalBitmap::AcquireBuffer( BOOL bReadOnly )
if ( mpVirDev != NULL )
{
- // Get the SalGraphics which contains the GWorld we will draw to
+ pBuffer = new BitmapBuffer();
- SalGraphics *pGraphics = GetGraphics();
-
- if ( ( pGraphics != NULL )
- && ( pGraphics->maGraphicsData.mpCGrafPort != NULL )
+ if ( ( pBuffer != NULL )
+ && ( mhPixMap != NULL )
+ && ( *mhPixMap != NULL )
)
{
- if ( mhPixMap != NULL )
- {
- // Lock the GWorld so that the calling functions
- // can write to this buffer
+ GWorldFlags nPixMapFlags = noErr;
- pGraphics->maGraphicsData.mnOSStatus
- = LockPortBits( pGraphics->maGraphicsData.mpCGrafPort );
+ nPixMapFlags = GetPixelsState( mhPixMap );
- if ( pGraphics->maGraphicsData.mnOSStatus == noErr )
+ if ( nPixMapFlags == noErr )
+ {
+ if ( LockPixels( mhPixMap ) )
{
- pBuffer = new BitmapBuffer();
+ const short nPixMapCmpCount = (**mhPixMap).cmpCount;
+ const short nPixMapCmpSize = (**mhPixMap).cmpSize;
- if ( pBuffer != NULL )
+ pBuffer->mnFormat = BMP_FORMAT_TOP_DOWN;
+
+ if( nPixMapCmpCount == 1 )
{
- pBuffer->mnFormat = BMP_FORMAT_TOP_DOWN;
- pBuffer->mnBitCount = GetPixDepth( mhPixMap);
+ // Indexed color mode
- switch ( pBuffer->mnBitCount )
+ switch ( nPixMapCmpSize )
{
- case kBlackAndWhite:
+ case ( kPixMapCmpSizeOneBit ):
pBuffer->mnFormat |= BMP_FORMAT_1BIT_MSB_PAL;
break;
- case kFourBitColor:
+ case ( kPixMapCmpSizeFourBits ):
pBuffer->mnFormat |= BMP_FORMAT_4BIT_MSN_PAL;
break;
- case kEightBitColor:
+ case ( kPixMapCmpSizeEightBits ):
pBuffer->mnFormat |= BMP_FORMAT_8BIT_PAL;
break;
- case kThousandsColor:
+ default:
+ break;
+ } // switch
+ } // if
+ else
+ {
+ // Direct color mode
+
+ switch ( nPixMapCmpSize )
+ {
+ case ( kPixMapCmpSizeFiveBits ):
pBuffer->mnFormat |= BMP_FORMAT_16BIT_TC_MASK;
- pBuffer->maColorMask = ColorMask( 0x7b00, 0x03e0, 0x001f);
+ pBuffer->maColorMask = ColorMask( 0x00007c00, 0x000003e0, 0x0000001f );
break;
- case kTrueColor:
- pBuffer->mnFormat |= BMP_FORMAT_32BIT_TC_ARGB;
+ case ( kPixMapCmpSizeEightBits ):
+ pBuffer->mnFormat |= BMP_FORMAT_32BIT_TC_ARGB;
+ pBuffer->maColorMask = ColorMask( 0x00ff0000, 0x0000ff00, 0x000000ff );
break;
default:
break;
- } // switch
+ } // switch;
+ } //else
- if ( BMP_SCANLINE_FORMAT( pBuffer->mnFormat ) )
- {
- GWorldFlags nGWorldFlags = noErr;
+ if ( BMP_SCANLINE_FORMAT( pBuffer->mnFormat ) )
+ {
+ pBuffer->mnWidth = mpVirDev->maVirDevData.mnWidth;
+ pBuffer->mnHeight = mpVirDev->maVirDevData.mnHeight;
+ pBuffer->mnScanlineSize = GetPixRowBytes( mhPixMap );
+ pBuffer->mpBits = (BYTE *)GetPixBaseAddr( mhPixMap );
+ pBuffer->mnBitCount = GetPixDepth( mhPixMap);
- pBuffer->mnWidth = mpVirDev->maVirDevData.mnWidth;
- pBuffer->mnHeight = mpVirDev->maVirDevData.mnHeight;
+ // If the pixel depth is <= 8, we need to map QD's
+ // internal color table to the platform independent
+ // BitmapPalette color table
- nGWorldFlags = GetPixelsState( mhPixMap );
+ if ( pBuffer->mnBitCount <= kEightBitColor )
+ {
+ CTabHandle hCTab = (**mhPixMap).pmTable;
- if ( nGWorldFlags == noErr )
+ if ( ( hCTab != NULL ) && ( *hCTab != NULL ) )
{
- LockPixels( mhPixMap );
+ SInt8 nCTabFlags = noErr;
- pBuffer->mnScanlineSize = GetPixRowBytes( mhPixMap );
- pBuffer->mpBits = (BYTE *)GetPixBaseAddr( mhPixMap );
+ nCTabFlags = HGetState( (Handle)hCTab );
- // If the pixel depth is <= 8, we need to map QD's
- // internal color table to the platform independent
- // BitmapPalette color table
-
- if ( pBuffer->mnBitCount <= 8 )
+ if ( nCTabFlags == noErr )
{
- CTabHandle hCTab = (**mhPixMap).pmTable;
+ USHORT nCTabSize = 0;
+ USHORT nCTabIndex = 0;
+ BitmapPalette &rBitmapPalette = pBuffer->maPalette;
- if ( ( hCTab != NULL ) && ( *hCTab != NULL ) )
- {
- SInt8 nCTabFlags = noErr;
+ HLock( (Handle)hCTab );
- nCTabFlags = HGetState( (Handle)hCTab );
+ // Map each color in the QuickDraw color
+ // table to a BitmapColor
- if ( nCTabFlags == noErr )
- {
- USHORT nCTabCount = 0;
- USHORT nCTabIndex = 0;
- BitmapPalette &rBitmapPalette = pBuffer->maPalette;
+ nCTabSize = (**hCTab).ctSize + 1;
- HLock( (Handle)hCTab );
-
- // Map each color in the QuickDraw color
- // table to a BitmapColor
-
- nCTabCount = (**hCTab).ctSize + 1;
-
- rBitmapPalette.SetEntryCount( nCTabCount );
-
- for ( nCTabIndex = 0;
- nCTabIndex < nCTabCount;
- nCTabIndex++
- )
- {
- BitmapColor &rBitmapColor = rBitmapPalette[nCTabIndex];
- ColorSpec aColorSpec = (**hCTab).ctTable[nCTabIndex];
+ rBitmapPalette.SetEntryCount( nCTabSize );
- rBitmapColor.SetRed ( (BYTE)( aColorSpec.rgb.red >> 8 ) );
- rBitmapColor.SetGreen ( (BYTE)( aColorSpec.rgb.green >> 8 ) );
- rBitmapColor.SetBlue ( (BYTE)( aColorSpec.rgb.blue >> 8 ) );
- } // for
-
- HSetState( (Handle)hCTab, nCTabFlags );
- } // if
- } // if
+ for ( nCTabIndex = 0;
+ nCTabIndex < nCTabSize;
+ nCTabIndex++
+ )
+ {
+ BitmapColor &rBitmapColor = rBitmapPalette[nCTabIndex];
+ const RGBColor aRGBColor = (**hCTab).ctTable[nCTabIndex].rgb;
+ const BYTE nRedColor = (BYTE)( aRGBColor.red >> 8 );
+ const BYTE nGreenColor = (BYTE)( aRGBColor.green >> 8 );
+ const BYTE nBlueColor = (BYTE)( aRGBColor.blue >> 8 );
+
+ rBitmapColor.SetRed ( nRedColor );
+ rBitmapColor.SetGreen ( nGreenColor );
+ rBitmapColor.SetBlue ( nBlueColor );
+ } // for
+
+ HSetState( (Handle)hCTab, nCTabFlags );
} // if
-
- SetPixelsState( mhPixMap, nGWorldFlags );
} // if
} // if
- else
- {
- UnlockPortBits( pGraphics->maGraphicsData.mpCGrafPort );
-
- ReleaseGraphics( pGraphics );
-
- delete pBuffer;
- } // else
} // if
-
- if ( pGraphics != NULL )
+ else
{
- UnlockPortBits( pGraphics->maGraphicsData.mpCGrafPort );
- } // if
- } // if
- } // if
-
- // Release the SalGraphics so that others can get a
- // handle to it in future GetGraphics() calls
+ delete pBuffer;
+ } // else
- if ( pGraphics != NULL )
- {
- ReleaseGraphics( pGraphics );
+ SetPixelsState( mhPixMap, nPixMapFlags );
+ } // if
} // if
} // if
} // if
@@ -1305,7 +1194,7 @@ void SalBitmap::ReleaseBuffer( BitmapBuffer* pBuffer, BOOL bReadOnly )
)
{
// Release the SalGraphics so that others can get a
- // handle to it in future GetGraphics() calls
+ // handle to it in future calls to GetGraphics()
ReleaseGraphics( pGraphics );
@@ -1315,6 +1204,115 @@ void SalBitmap::ReleaseBuffer( BitmapBuffer* pBuffer, BOOL bReadOnly )
if ( pBuffer != NULL )
{
+ if ( !bReadOnly )
+ {
+ if ( ( mhPixMap != NULL ) && (*mhPixMap != NULL ) )
+ {
+ GWorldFlags nPixMapFlags = noErr;
+
+ nPixMapFlags = GetPixelsState( mhPixMap );
+
+ if ( nPixMapFlags == noErr )
+ {
+ if ( LockPixels( mhPixMap ) )
+ {
+ if ( !!pBuffer->maPalette )
+ {
+ CTabHandle hCTab = (**mhPixMap).pmTable;
+
+ if ( ( hCTab != NULL ) && ( *hCTab != NULL ) )
+ {
+ SInt8 nCTabFlags = noErr;
+
+ nCTabFlags = HGetState( (Handle)hCTab );
+
+ if ( nCTabFlags == noErr )
+ {
+ const BitmapPalette &rBitmapPalette = pBuffer->maPalette;
+ const short nCTabSize = (**hCTab).ctSize + 1;
+ const short nCTabMinSize = GetMinColorCount( nCTabSize, rBitmapPalette );
+ short nCTabIndex;
+
+ HLock( (Handle)hCTab );
+
+ for( nCTabIndex = 0;
+ nCTabIndex < nCTabMinSize;
+ nCTabIndex++
+ )
+ {
+ const BitmapColor &rBitmapColor = rBitmapPalette[nCTabIndex];
+ const USHORT nBitmapRedColor = rBitmapColor.GetRed();
+ const USHORT nBitmapGreenColor = rBitmapColor.GetGreen();
+ const USHORT nBitmapBlueColor = rBitmapColor.GetBlue();
+
+ (**hCTab).ctTable[nCTabIndex].value = nCTabIndex;
+
+ (**hCTab).ctTable[nCTabIndex].rgb.red
+ = (short)(( nBitmapRedColor << 8 ) | nBitmapRedColor);
+
+ (**hCTab).ctTable[nCTabIndex].rgb.green
+ = (short)(( nBitmapGreenColor << 8 ) | nBitmapGreenColor) ;
+
+ (**hCTab).ctTable[nCTabIndex].rgb.blue
+ = (short)(( nBitmapBlueColor << 8 ) | nBitmapBlueColor);
+ } // for
+
+ HSetState( (Handle)hCTab, nCTabFlags );
+ } // if
+ } // if
+ } // if
+ else
+ {
+ GDPtr pGDevice = NULL;
+
+ pGDevice = *GetGDevice();
+
+ if ( pGDevice != NULL )
+ {
+ PixMapPtr pPixMap = *pGDevice->gdPMap;
+
+ if ( pPixMap != NULL )
+ {
+ 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();
+ pPixMap = *pGDevice->gdPMap;
+ } // if
+ } // if
+
+ (**mhPixMap).pmTable = pPixMap->pmTable;
+ } // if
+ else
+ {
+ (**mhPixMap).pmTable = NULL;
+ } // else
+ } // if
+ } // if
+ } // else
+
+ SetPixelsState( mhPixMap, nPixMapFlags );
+ } // if
+ } //if
+ } // if
+ } // if
+
delete pBuffer;
pBuffer = NULL;
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
diff --git a/vcl/aqua/source/gdi/salvd.cxx b/vcl/aqua/source/gdi/salvd.cxx
index 5ea84e340d00..10ecfafecc21 100644
--- a/vcl/aqua/source/gdi/salvd.cxx
+++ b/vcl/aqua/source/gdi/salvd.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: salvd.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: bmahbod $ $Date: 2001-01-31 23:56:13 $
+ * 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
@@ -214,6 +214,8 @@ SalGraphics* SalVirtualDevice::GetGraphics()
maVirDevData.mbGraphics = InitVirtualDeviceGWorld( &maVirDevData );
} // if
+ maVirDevData.mbGraphics = TRUE;
+
return maVirDevData.mpGraphics;
} // SalVirtualDevice::GetGraphics
@@ -241,7 +243,7 @@ BOOL SalVirtualDevice::SetSize( long nDX, long nDY )
if ( maVirDevData.mpGraphics->maGraphicsData.mpCGrafPort != NULL )
{
- DisposePort( maVirDevData.mpGraphics->maGraphicsData.mpCGrafPort );
+ DisposeGWorld( maVirDevData.mpGraphics->maGraphicsData.mpCGrafPort );
maVirDevData.mpGraphics->maGraphicsData.mpGWorld = NULL;
maVirDevData.mpGraphics->maGraphicsData.mpCGrafPort = NULL;