home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.ms-windows.programmer.misc
- Path: sparky!uunet!utcsri!torn!cunews!nrcnet0!emr1!jagrant
- From: jagrant@emr1.emr.ca (John Grant)
- Subject: can't get R2_XOR to work
- Message-ID: <1992Sep16.042845.4155@emr1.emr.ca>
- Organization: Energy, Mines, and Resources, Ottawa
- References: <1992Sep16.042818.4073@emr1.emr.ca>
- Date: Wed, 16 Sep 1992 04:28:45 GMT
- Lines: 51
-
- I tested R2_XORPEN mode & although the XOR works (first time draws,
- 2nd time erases), the colours are not as expected.
-
- in response to WM_PAINT, I do the following:
- #define BACKCOLOUR RGB(255,0,0) //red
- #define LINECOLOUR RGB(255,255,0) //yellow
- #define COLOUR2 BACKCOLOUR^LINECOLOUR //green
- hdc=BeginPaint(hwnd,&ps);
- GetClientRect(hwnd,&rect);
- xsize=rect.right /4;
- ysize=rect.bottom/4;
-
- //draw background
- hbrush=SelectObject(hdc,(HBRUSH)CreateSolidBrush(BACKCOLOUR));
- Rectangle(hdc,rect.left,rect.top,rect.right,rect.bottom);
- DeleteObject(SelectObject(hdc,hbrush));
-
- SetROP2(hdc,R2_XORPEN);
-
- //draw line
- hpen=SelectObject(hdc,(HPEN)CreatePen(PS_SOLID,5,LINECOLOUR));
- MoveTo(hdc,xsize, ysize/2);
- LineTo(hdc,xsize*2,ysize/2);
- DeleteObject(SelectObject(hdc,hpen));
-
- //draw rectangle
- hbrush=SelectObject(hdc,(HBRUSH)CreateSolidBrush(LINECOLOUR));
- Rectangle(hdc,xsize,ysize,xsize*2,ysize*2);
- DeleteObject(SelectObject(hdc,hbrush));
-
- //draw another line
- hpen=SelectObject(hdc,(HPEN)CreatePen(PS_SOLID,5,COLOUR2));
- MoveTo(hdc,xsize*2,ysize/2);
- LineTo(hdc,xsize*3,ysize/2);
- DeleteObject(SelectObject(hdc,hpen));
-
- //draw another rectangle
- hbrush=SelectObject(hdc,(HBRUSH)CreateSolidBrush(COLOUR2));
- Rectangle(hdc,xsize*2,ysize,xsize*3,ysize*2);
- DeleteObject(SelectObject(hdc,hbrush));
-
- EndPaint(hwnd,&ps);
-
- Lines AND rectangles are both drawn to verify XOR with pen & brush
- painting. The background is RED (correct). The first line & rectangle
- use colour YELLOW. The result should be bright GREEN, i.e. RGB(0,255,0)
- which is RED^YELLOW. It IS green, but it is a drab olive green instead
- of RGB(0,255,0). The next line & rectangle use colour RED^YELLOW which
- should be GREEN & the result should be YELLOW. Instead I get a 'tan'
- colour (sort of yellow). What is wrong here? I am using an ATI card
- in 16-colour VGA mode & all colours appear as pure (non-dithered).
-