Tk Source Code

View Ticket
Login
Ticket UUID: 220699
Title: "winfo rgb" gives different results between Unix and Windows
Type: Bug Version: obsolete: 8.3
Submitter: welch Created on: 2000-10-31 23:51:02
Subsystem: 30. Color Names Assigned To: nobody
Priority: 2 Severity:
Status: Closed Last Modified: 2001-03-28 05:01:45
Resolution: Fixed Closed By: dgp
    Closed on: 2001-03-27 22:01:45
Description:
OriginalBugID: 4282 Bug
Version: 8.3
SubmitDate: '2000-03-01'
LastModified: '2000-03-02'
Severity: MED
Status: Released
Submitter: techsupp
ChangedBy: hobbs
OS: All Windows
FixedDate: '2000-03-02'
FixedInVersion: 8.3.1


Name: Greg Couch



Comments:

We're actually using 8.0.5, but xlib/xcolors.c is the same in 8.3.0.



ReproducibleScript:

Give the tcl command "winfo rgb . red" in wish.



ObservedBehavior:

On Windows you get "65280 0 0".



DesiredBehavior:

On Unix, you get back "65535 0 0".



Patch:

*** xcolors.c   2000/03/02 00:50:17     1.1

--- xcolors.c   2000/03/02 00:59:00

***************

*** 854,862 ****

      if (l > u) {

        return 0;

      }

!     colorPtr->red = xColors[i].red << 8;

!     colorPtr->green = xColors[i].green << 8;

!     colorPtr->blue = xColors[i].blue << 8;

      return 1;

  }

  



--- 854,862 ----

      if (l > u) {

        return 0;

      }

!     colorPtr->red = (xColors[i].red << 8) | xColors[i].red; 

!     colorPtr->green = (xColors[i].green << 8) | xColors[i].green;

!     colorPtr->blue = (xColors[i].blue << 8) | xColors[i].blue;

      return 1;

  }



PatchFiles:

xcolors.c





Applying this patch had no effect on the end result, although

it seems straightforward.  Also a problem is XParseColor in the

same file, that will cause the following bad result:

    winfo rgb . #ff0000

=>  65280 0 0 

-- 03/02/2000 hobbs

Needed similar patch in XParseColor in xcolors.c and also:



===================================================================

RCS file: RCS/tkWinColor.c,v

retrieving revision 1.1

diff -c -r1.1 tkWinColor.c

*** tkWinColor.c2000/03/02 19:06:191.1

--- tkWinColor.c2000/03/02 19:13:36

***************

*** 373,381 ****

  

  if ((index >= cmap->size) || (newPixel != closePixel)) {

      if (cmap->size == sizePalette) {

! color->red = closeEntry.peRed << 8;

! color->green = closeEntry.peGreen << 8;

! color->blue = closeEntry.peBlue << 8;

  entry = closeEntry;

  if (index >= cmap->size) {

      OutputDebugString("XAllocColor: Colormap is bigger than we thought");

--- 373,381 ----

  

  if ((index >= cmap->size) || (newPixel != closePixel)) {

      if (cmap->size == sizePalette) {

! color->red = (closeEntry.peRed << 8) | closeEntry.peRed;

! color->green = (closeEntry.peGreen << 8) | closeEntry.peGreen;

! color->blue = (closeEntry.peBlue << 8) | closeEntry.peBlue;

  entry = closeEntry;

  if (index >= cmap->size) {

      OutputDebugString("XAllocColor: Colormap is bigger than we thought");

***************

*** 404,412 ****

  

  color->pixel = GetNearestColor(dc,

  RGB(entry.peRed, entry.peGreen, entry.peBlue));

! color->red = (GetRValue(color->pixel) << 8);

! color->green = (GetGValue(color->pixel) << 8);

! color->blue = (GetBValue(color->pixel) << 8);

      }

  

      ReleaseDC(NULL, dc);

--- 404,412 ----

  

  color->pixel = GetNearestColor(dc,

  RGB(entry.peRed, entry.peGreen, entry.peBlue));

! color->red = (GetRValue(color->pixel) << 8) | GetRValue(color->pixel);

! color->green = (GetGValue(color->pixel) << 8) | GetGValue(color->pixel);

! color->blue = (GetBValue(color->pixel) << 8) | GetBValue(color->pixel);

      }

  

      ReleaseDC(NULL, dc);



Patched for 8.3.1. 

-- 03/02/2000 hobbs