@@ -27,7 +27,7 @@ static Pixel make_pixel (unsigned char r, unsigned char g, unsigned char b,
2727 g >>= (8 - bprgb);
2828 b >>= (8 - bprgb);
2929 }
30- return (r << rs ) | (g << gs ) | (b << bs );
30+ return (r << 16 ) | (g << 8 ) | (b << 0 );
3131}
3232
3333// -------------------------------------------------------------------
@@ -396,7 +396,11 @@ int Palette::ReadSeqPalette(const string &fileName, bool bRedraw) {
396396 bTrueColor = gaPtr->IsTrueColor ();
397397 bprgb = gaPtr->PBitsPerRGB ();
398398 }
399-
399+
400+ unsigned long rs (gaPtr->PRedShift ());
401+ unsigned long gs (gaPtr->PGreenShift ());
402+ unsigned long bs (gaPtr->PBlueShift ());
403+
400404 if (bReadPalette) {
401405 bReadPalette = false ;
402406 rbuff.resize (iSeqPalSize);
@@ -408,7 +412,7 @@ int Palette::ReadSeqPalette(const string &fileName, bool bRedraw) {
408412 cout << " Can't open colormap file: " << fileName << endl;
409413 for (i = 0 ; i < totalColorSlots; ++i) { // make a default grayscale colormap.
410414 if (bTrueColor) {
411- ccells[i].pixel = make_pixel (rbuff[i], gbuff[i], bbuff[i], bprgb, 2 *bprgb, bprgb, 0 );
415+ ccells[i].pixel = make_pixel (rbuff[i], gbuff[i], bbuff[i], bprgb, rs, gs, bs );
412416 } else {
413417 ccells[i].pixel = i;
414418 }
@@ -497,7 +501,7 @@ int Palette::ReadSeqPalette(const string &fileName, bool bRedraw) {
497501 cout << "making a CCPal colormap" << endl;
498502 for(i = 0; i < totalColorSlots; ++i) {
499503 if(bTrueColor) {
500- ccells[i].pixel = make_pixel(rbuff[i], gbuff[i], bbuff[i], bprgb, 2*bprgb, bprgb, 0 );
504+ ccells[i].pixel = make_pixel(rbuff[i], gbuff[i], bbuff[i], bprgb, rs, gs, bs );
501505 } else {
502506 ccells[i].pixel = i;
503507 }
@@ -626,9 +630,6 @@ int Palette::ReadSeqPalette(const string &fileName, bool bRedraw) {
626630
627631 Real dimValue (0.4 );
628632 if (bTrueColor) {
629- unsigned long rs (gaPtr->PRedShift ());
630- unsigned long gs (gaPtr->PGreenShift ());
631- unsigned long bs (gaPtr->PBlueShift ());
632633 for (i = 0 ; i < iSeqPalSize; ++i) {
633634 pixelCache[i] = make_pixel (rbuff[i], gbuff[i], bbuff[i], bprgb, rs, gs, bs);
634635 pixelCacheDim[i] = make_pixel (static_cast <unsigned char >(rbuff[i] * dimValue),
@@ -645,7 +646,7 @@ int Palette::ReadSeqPalette(const string &fileName, bool bRedraw) {
645646
646647 for (i = 0 ; i < totalColorSlots; ++i) {
647648 if (bTrueColor) {
648- ccells[i].pixel = make_pixel (rbuff[i], gbuff[i], bbuff[i], bprgb, 2 *bprgb, bprgb, 0 );
649+ ccells[i].pixel = make_pixel (rbuff[i], gbuff[i], bbuff[i], bprgb, rs, gs, bs );
649650 } else {
650651 ccells[i].pixel = i;
651652 }
0 commit comments