we now call GetNearestColor() in 16bpp when creating brushes and pens.

This commit is contained in:
michaelp%netscape.com 1998-12-15 23:13:59 +00:00
parent fb0f8afdb2
commit 361c8080ab
2 changed files with 33 additions and 6 deletions

View File

@ -366,6 +366,7 @@ nsRenderingContextWin :: nsRenderingContextWin()
#endif
mSurface = nsnull;
mMainSurface = nsnull;
mGetNearestColor = PR_FALSE;
mStateCache = new nsVoidArray();
@ -660,6 +661,13 @@ nsresult nsRenderingContextWin :: CommonInit(void)
mTMatrix->AddScale(app2dev, app2dev);
mContext->GetDevUnitsToAppUnits(mP2T);
PRUint32 depth;
mContext->GetDepth(depth);
if (16 == depth)
mGetNearestColor = PR_TRUE;
#ifdef NS_DEBUG
mInitialized = PR_TRUE;
#endif
@ -1784,9 +1792,12 @@ HBRUSH nsRenderingContextWin :: SetupSolidBrush(void)
{
if ((mCurrentColor != mCurrBrushColor) || (NULL == mCurrBrush))
{
// XXX In 16-bit mode we need to use GetNearestColor() to get a solid
// color; otherwise, we'll end up with a dithered brush...
HBRUSH tbrush = ::CreateSolidBrush(PALETTERGB_COLORREF(mColor));
HBRUSH tbrush;
if (PR_TRUE == mGetNearestColor)
tbrush = ::CreateSolidBrush(PALETTERGB_COLORREF(::GetNearestColor(mDC, mColor)));
else
tbrush = ::CreateSolidBrush(PALETTERGB_COLORREF(mColor));
::SelectObject(mDC, tbrush);
@ -1859,7 +1870,12 @@ HPEN nsRenderingContextWin :: SetupSolidPen(void)
{
if ((mCurrentColor != mCurrPenColor) || (NULL == mCurrPen) || (mCurrPen != mStates->mSolidPen))
{
HPEN tpen = ::CreatePen(PS_SOLID, 0, PALETTERGB_COLORREF(mColor));
HPEN tpen;
if (PR_TRUE == mGetNearestColor)
tpen = ::CreatePen(PS_SOLID, 0, PALETTERGB_COLORREF(::GetNearestColor(mDC, mColor)));
else
tpen = ::CreatePen(PS_SOLID, 0, PALETTERGB_COLORREF(mColor));
::SelectObject(mDC, tpen);
@ -1878,7 +1894,12 @@ HPEN nsRenderingContextWin :: SetupDashedPen(void)
{
if ((mCurrentColor != mCurrPenColor) || (NULL == mCurrPen) || (mCurrPen != mStates->mDashedPen))
{
HPEN tpen = ::CreatePen(PS_DASH, 0, PALETTERGB_COLORREF(mColor));
HPEN tpen;
if (PR_TRUE == mGetNearestColor)
tpen = ::CreatePen(PS_DASH, 0, PALETTERGB_COLORREF(::GetNearestColor(mDC, mColor)));
else
tpen = ::CreatePen(PS_DASH, 0, PALETTERGB_COLORREF(mColor));
::SelectObject(mDC, tpen);
@ -1897,7 +1918,12 @@ HPEN nsRenderingContextWin :: SetupDottedPen(void)
{
if ((mCurrentColor != mCurrPenColor) || (NULL == mCurrPen) || (mCurrPen != mStates->mDottedPen))
{
HPEN tpen = ::CreatePen(PS_DOT, 0, PALETTERGB_COLORREF(mColor));
HPEN tpen;
if (PR_TRUE == mGetNearestColor)
tpen = ::CreatePen(PS_DOT, 0, PALETTERGB_COLORREF(::GetNearestColor(mDC, mColor)));
else
tpen = ::CreatePen(PS_DOT, 0, PALETTERGB_COLORREF(mColor));
::SelectObject(mDC, tpen);

View File

@ -217,6 +217,7 @@ protected:
PRUint8 *mGammaTable;
COLORREF mCurrTextColor;
nsLineStyle mCurrLineStyle;
PRBool mGetNearestColor;
#ifdef NS_DEBUG
PRBool mInitialized;