home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / os / mswindo / programm / misc / 1865 < prev    next >
Encoding:
Text File  |  1992-09-15  |  2.3 KB  |  62 lines

  1. Newsgroups: comp.os.ms-windows.programmer.misc
  2. Path: sparky!uunet!utcsri!torn!cunews!nrcnet0!emr1!jagrant
  3. From: jagrant@emr1.emr.ca (John Grant)
  4. Subject: can't get R2_XOR to work
  5. Message-ID: <1992Sep16.042845.4155@emr1.emr.ca>
  6. Organization: Energy, Mines, and Resources, Ottawa
  7. References: <1992Sep16.042818.4073@emr1.emr.ca>
  8. Date: Wed, 16 Sep 1992 04:28:45 GMT
  9. Lines: 51
  10.  
  11. I tested R2_XORPEN mode & although the XOR works (first time draws, 
  12. 2nd time erases), the colours are not as expected.
  13.  
  14. in response to WM_PAINT, I do the following:
  15. #define BACKCOLOUR      RGB(255,0,0)            //red
  16. #define LINECOLOUR      RGB(255,255,0)          //yellow
  17. #define COLOUR2         BACKCOLOUR^LINECOLOUR   //green
  18.     hdc=BeginPaint(hwnd,&ps);
  19.     GetClientRect(hwnd,&rect);
  20.     xsize=rect.right /4;
  21.     ysize=rect.bottom/4;
  22.  
  23.     //draw background
  24.     hbrush=SelectObject(hdc,(HBRUSH)CreateSolidBrush(BACKCOLOUR));
  25.     Rectangle(hdc,rect.left,rect.top,rect.right,rect.bottom);
  26.     DeleteObject(SelectObject(hdc,hbrush));
  27.  
  28.     SetROP2(hdc,R2_XORPEN);
  29.  
  30.     //draw line
  31.     hpen=SelectObject(hdc,(HPEN)CreatePen(PS_SOLID,5,LINECOLOUR));
  32.     MoveTo(hdc,xsize,  ysize/2);
  33.     LineTo(hdc,xsize*2,ysize/2);
  34.     DeleteObject(SelectObject(hdc,hpen));
  35.  
  36.     //draw rectangle
  37.     hbrush=SelectObject(hdc,(HBRUSH)CreateSolidBrush(LINECOLOUR));
  38.     Rectangle(hdc,xsize,ysize,xsize*2,ysize*2);
  39.     DeleteObject(SelectObject(hdc,hbrush));
  40.  
  41.     //draw another line
  42.     hpen=SelectObject(hdc,(HPEN)CreatePen(PS_SOLID,5,COLOUR2));
  43.     MoveTo(hdc,xsize*2,ysize/2);
  44.     LineTo(hdc,xsize*3,ysize/2);
  45.     DeleteObject(SelectObject(hdc,hpen));
  46.  
  47.     //draw another rectangle
  48.     hbrush=SelectObject(hdc,(HBRUSH)CreateSolidBrush(COLOUR2));
  49.     Rectangle(hdc,xsize*2,ysize,xsize*3,ysize*2);
  50.     DeleteObject(SelectObject(hdc,hbrush));
  51.  
  52.     EndPaint(hwnd,&ps);
  53.  
  54. Lines AND rectangles are both drawn to verify XOR with pen & brush
  55. painting.  The background is RED (correct).  The first line & rectangle
  56. use colour YELLOW.  The result should be bright GREEN, i.e. RGB(0,255,0)
  57. which is RED^YELLOW.  It IS green, but it is a drab olive green instead
  58. of RGB(0,255,0).  The next line & rectangle use colour RED^YELLOW which
  59. should be GREEN & the result should be YELLOW.  Instead I get a 'tan'
  60. colour (sort of yellow).  What is wrong here?  I am using an ATI card
  61. in 16-colour VGA mode & all colours appear as pure (non-dithered).
  62.