r=mkaply, a=blizzard
Code from dainis - workaround postscript bug where GpiQueryColorIndex doesn't work
This commit is contained in:
mkaply%us.ibm.com 2001-03-07 02:25:00 +00:00
Родитель 6c2fa5af6a
Коммит be81f6a7fa
2 изменённых файлов: 18 добавлений и 7 удалений

Просмотреть файл

@ -452,8 +452,14 @@ nsImageOS2::DrawTile(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
// Set image foreground and background colors. These are used in transparent images for blitting 1-bit masks. // Set image foreground and background colors. These are used in transparent images for blitting 1-bit masks.
// To invert colors on ROP_SRCAND we map 1 to black and 0 to white // To invert colors on ROP_SRCAND we map 1 to black and 0 to white
IMAGEBUNDLE ib; IMAGEBUNDLE ib;
ib.lColor = GFX (::GpiQueryColorIndex (MemPS, 0, MK_RGB (0, 0, 0)), GPI_ALTERROR); // map 1 in mask to 0x000000 (black) in destination ib.lColor = GFX (::GpiQueryColorIndex (MemPS, 0, MK_RGB (0x00, 0x00, 0x00)), GPI_ALTERROR); // CLR_BLACK
ib.lBackColor = GFX (::GpiQueryColorIndex (MemPS, 0, MK_RGB (255, 255, 255)), GPI_ALTERROR); // map 0 in mask to 0xFFFFFF (white) in destination if (ib.lColor == -1) {
ib.lColor = MK_RGB (0x00, 0x00, 0x00);
}
ib.lBackColor = GFX (::GpiQueryColorIndex (MemPS, 0, MK_RGB (0xFF, 0xFF, 0xFF)), GPI_ALTERROR); // CLR_WHITE
if (ib.lBackColor == -1) {
ib.lBackColor = MK_RGB (0xFF, 0xFF, 0xFF);
}
ib.usMixMode = FM_OVERPAINT; ib.usMixMode = FM_OVERPAINT;
ib.usBackMixMode = BM_OVERPAINT; ib.usBackMixMode = BM_OVERPAINT;
GFX (::GpiSetAttrs (MemPS, PRIM_IMAGE, IBB_COLOR | IBB_BACK_COLOR | IBB_MIX_MODE | IBB_BACK_MIX_MODE, 0, (PBUNDLE)&ib), FALSE); GFX (::GpiSetAttrs (MemPS, PRIM_IMAGE, IBB_COLOR | IBB_BACK_COLOR | IBB_MIX_MODE | IBB_BACK_MIX_MODE, 0, (PBUNDLE)&ib), FALSE);

Просмотреть файл

@ -314,6 +314,12 @@ nsresult nsRenderingContextOS2::CommonInit()
nsPaletteInfo palInfo; nsPaletteInfo palInfo;
mContext->GetPaletteInfo(palInfo); mContext->GetPaletteInfo(palInfo);
// Set image foreground and background colors. These are used in transparent images for blitting 1-bit masks.
// To invert colors on ROP_SRCAND we map 1 to black and 0 to white
// map 1 in mask to 0x000000 (black) in destination
// map 0 in mask to 0xFFFFFF (white) in destination
IMAGEBUNDLE ib;
if (palInfo.isPaletteDevice && palInfo.palette) if (palInfo.isPaletteDevice && palInfo.palette)
{ {
ULONG cclr; ULONG cclr;
@ -323,17 +329,16 @@ nsresult nsRenderingContextOS2::CommonInit()
if (mDCOwner) { if (mDCOwner) {
::WinRealizePalette((HWND)mDCOwner->GetNativeData(NS_NATIVE_WINDOW),mSurface->mPS, &cclr); ::WinRealizePalette((HWND)mDCOwner->GetNativeData(NS_NATIVE_WINDOW),mSurface->mPS, &cclr);
} /* endif */ } /* endif */
ib.lColor = GFX (::GpiQueryColorIndex (mSurface->mPS, 0, MK_RGB (0x00, 0x00, 0x00)), GPI_ALTERROR); // CLR_BLACK
ib.lBackColor = GFX (::GpiQueryColorIndex (mSurface->mPS, 0, MK_RGB (0xFF, 0xFF, 0xFF)), GPI_ALTERROR); // CLR_WHITE
} }
else else
{ {
GFX (::GpiCreateLogColorTable (mSurface->mPS, 0, LCOLF_RGB, 0, 0, 0), FALSE); GFX (::GpiCreateLogColorTable (mSurface->mPS, 0, LCOLF_RGB, 0, 0, 0), FALSE);
ib.lColor = MK_RGB (0x00, 0x00, 0x00); // CLR_BLACK
ib.lBackColor = MK_RGB (0xFF, 0xFF, 0xFF); // CLR_WHITE
} }
// Set image foreground and background colors. These are used in transparent images for blitting 1-bit masks.
// To invert colors on ROP_SRCAND we map 1 to black and 0 to white
IMAGEBUNDLE ib;
ib.lColor = GFX (::GpiQueryColorIndex (mSurface->mPS, 0, MK_RGB (0, 0, 0)), GPI_ALTERROR); // map 1 in mask to 0x000000 (black) in destination
ib.lBackColor = GFX (::GpiQueryColorIndex (mSurface->mPS, 0, MK_RGB (255, 255, 255)), GPI_ALTERROR); // map 0 in mask to 0xFFFFFF (white) in destination
ib.usMixMode = FM_OVERPAINT; ib.usMixMode = FM_OVERPAINT;
ib.usBackMixMode = BM_OVERPAINT; ib.usBackMixMode = BM_OVERPAINT;
GFX (::GpiSetAttrs (mSurface->mPS, PRIM_IMAGE, IBB_COLOR | IBB_BACK_COLOR | IBB_MIX_MODE | IBB_BACK_MIX_MODE, 0, (PBUNDLE)&ib), FALSE); GFX (::GpiSetAttrs (mSurface->mPS, PRIM_IMAGE, IBB_COLOR | IBB_BACK_COLOR | IBB_MIX_MODE | IBB_BACK_MIX_MODE, 0, (PBUNDLE)&ib), FALSE);