Add some 8-bit color support + removed bit conversion in nsImageUnix.cpp Draw.

This commit is contained in:
kmcclusk%netscape.com 1998-09-01 21:24:32 +00:00
Родитель a7aaeaacf7
Коммит 591fc90098
3 изменённых файлов: 54 добавлений и 17 удалений

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

@ -34,6 +34,8 @@ static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
#define NS_TO_X(a) (NS_TO_X_RED(a) | NS_TO_X_GREEN(a) | NS_TO_X_BLUE(a))
#define COLOR_CUBE_SIZE 216
nsDeviceContextUnix :: nsDeviceContextUnix()
{
@ -52,6 +54,10 @@ nsDeviceContextUnix :: nsDeviceContextUnix()
mBlueOffset = 0;
mDepth = 0 ;
mColormap = 0 ;
mPaletteInfo.isPaletteDevice = PR_FALSE;
mPaletteInfo.sizePalette = 0;
mPaletteInfo.numReserved = 0;
mPaletteInfo.palette = NULL;
}
nsDeviceContextUnix :: ~nsDeviceContextUnix()
@ -292,8 +298,15 @@ void nsDeviceContextUnix :: InstallColormap(Display* aDisplay, Drawable aDrawabl
// Check to see if the colormap is writable
mVisual = wa.visual;
if (mVisual->c_class != TrueColor)
mPaletteInfo.isPaletteDevice = PR_TRUE;
else
mPaletteInfo.isPaletteDevice = PR_FALSE;
if (mVisual->c_class == GrayScale || mVisual->c_class == PseudoColor || mVisual->c_class == DirectColor)
{
mWriteable = PR_TRUE;
}
else // We have StaticGray, StaticColor or TrueColor
mWriteable = PR_FALSE;
@ -421,10 +434,33 @@ NS_IMETHODIMP nsDeviceContextUnix::GetILColorSpace(IL_ColorSpace*& aColorSpace)
InstallColormap();
if (nsnull == mColorSpace) {
if (16 == mDepth) {
if ((8 == mDepth) && mPaletteInfo.isPaletteDevice) {
//
// 8-BIT Visual
//
// Create a color cube. We want to use DIB_PAL_COLORS because it's faster
// than DIB_RGB_COLORS, so make sure the indexes match that of the
// GDI physical palette
//
// Note: the image library doesn't use the reserved colors, so it doesn't
// matter what they're set to...
IL_RGB reserved[10];
memset(reserved, 0, sizeof(reserved));
IL_ColorMap* colorMap = IL_NewCubeColorMap(reserved, 10, COLOR_CUBE_SIZE + 10);
if (nsnull == colorMap) {
return NS_ERROR_OUT_OF_MEMORY;
}
// Create a pseudo color space
mColorSpace = IL_CreatePseudoColorSpace(colorMap, 8, 8);
} else if (16 == mDepth) {
//
// 16-BIT Visual
//
IL_RGBBits colorRGBBits;
// Default is to create a 16-bit color space
colorRGBBits.red_shift = mRedOffset;
colorRGBBits.red_bits = mRedBits;
colorRGBBits.green_shift = mGreenOffset;

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

@ -83,6 +83,7 @@ protected:
PRBool mWriteable;
PRUint32 mNumCells;
Colormap mColormap;
nsPaletteInfo mPaletteInfo;
public:
void InstallColormap(void);

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

@ -259,7 +259,6 @@ PRUint8 *srcbits;
}
return(PR_FALSE);
}
@ -280,6 +279,7 @@ PRUint16 red,green,blue,*cur16;
mBitsForCreate = mImageBits;
#if 0
if((unixdrawing->depth==24) && (mOriginalDepth==8))
{
// convert this nsImage to a 24 bit image
@ -357,7 +357,7 @@ PRUint16 red,green,blue,*cur16;
}
#endif
}
#endif
}
nsresult nsImageUnix::BuildImage(nsDrawingSurface aDrawingSurface)