-
Notifications
You must be signed in to change notification settings - Fork 0
/
misc.cxx
722 lines (591 loc) · 21 KB
/
misc.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
// $Id: misc.cpp,v 1.11 2003/05/07 23:41:23 schmidap Exp $
// Written by:
// Grant Macklem (Grant.Macklem@colorado.edu)
// Gregory Schmelter (Gregory.Schmelter@colorado.edu)
// Alan Schmidt (Alan.Schmidt@colorado.edu)
// Ivan Stashak (Ivan.Stashak@colorado.edu)
// CSCI 4830/7818: API Programming
// University of Colorado at Boulder, Spring 2003
// http://www.cs.colorado.edu/~main/bgi
//
#include <windows.h> // Provides Win32 API
#include <windowsx.h> // Provides GDI helper macros
#include "winbgi.h" // API routines
#include "winbgitypes.h" // Internal structure data
/*****************************************************************************
*
* Structures
*
*****************************************************************************/
struct LinePattern
{
int width;
DWORD pattern[16];
};
/*****************************************************************************
*
* Global Variables
*
*****************************************************************************/
// Solid line: 0xFFFF
// Dotted line: 0011 0011 0011 0011b dot space
// Center line: 0001 1110 0011 1111b dot space dash space
// Dashed line: 0001 1111 0001 1111b dash space
// The numbers in the pattern (of the LinePattern struct) represent the width
// in pixels of the first dash, then the first space, then the next dash, etc.
// A leading space is moved to the end.
// The dash is one longer than specified; the space is one shorter.
// Creating a geometric pen using the predefined constants produces
// poor results. Thus, the above widths have been modifed:
// Space: 3 pixels
// Dash: 8 pixels
// Dot: 4 pixels
LinePattern SOLID = { 2, {16, 0} }; // In reality, these are (see note above)
LinePattern DOTTED = { 2, {3, 4} }; // 4, 3
LinePattern CENTER = { 4, {3, 4, 7, 4} }; // 4, 3, 8, 3
LinePattern DASHED = {2, {7, 4} }; // 8, 3
// Color format:
// High byte: 0 Color is an index, BGI color
// -- This is necessary since these colors are defined to be 0-15 in BGI
// High byte: 3 Color is an RGB value (page 244 of Win32 book)
// -- Note the internal COLORREF structure has RGB values with a high byte
// of 0, but this conflicts with the BGI color notation.
// We store the value the user gave internally (be it number 4 for RED or
// our RGB encoded value). This is then converted when needed.
// From http://www.textmodegames.com/articles/coolgame.html
// Then used BGI graphics on my system for slight modification.
COLORREF BGI__Colors[16];
// These are set in graphdefaults in winbgi.cpp
/*
= {
RGB( 0, 0, 0 ), // Black
RGB( 0, 0, 168), // Blue
RGB( 0, 168, 0 ), // Green
RGB( 0, 168, 168 ), // Cyan
RGB( 168, 0, 0 ), // Red
RGB( 168, 0, 168 ), // Magenta
RGB( 168, 84, 0 ), // Brown
RGB( 168, 168, 168 ), // Light Gray
RGB( 84, 84, 84 ), // Dark Gray
RGB( 84, 84, 252 ), // Light Blue
RGB( 84, 252, 84 ), // Light Green
RGB( 84, 252, 252 ), // Light Cyan
RGB( 252, 84, 84 ), // Light Red
RGB( 252, 84, 252 ), // Light Magenta
RGB( 252, 252, 84 ), // Yellow
RGB( 252, 252, 252 ) // White
};
*/
/*****************************************************************************
*
* Prototypes
*
*****************************************************************************/
LinePattern CreateUserStyle( );
/*****************************************************************************
*
* Helper functions
*
*****************************************************************************/
// This function converts a given color (specified by the user) into a format
// native to windows.
//
int converttorgb( int color )
{
// Convert from BGI color to RGB color
if ( IS_BGI_COLOR( color ) )
color = BGI__Colors[color];
else
color &= 0x0FFFFFF;
return color;
}
#include <iostream>
// This function creates a new pen in the current drawing color and selects it
// into all the memory DC's.
//
void CreateNewPen( )
{
WindowData* pWndData = BGI__GetWindowDataPtr( );
int color = pWndData->drawColor;;
LinePattern style;
LOGBRUSH lb;
HPEN hPen;
// Convert from BGI color to RGB color
color = converttorgb( color );
// Set the color and style of the logical brush
lb.lbColor = color;
lb.lbStyle = BS_SOLID;
if ( pWndData->lineInfo.linestyle == SOLID_LINE ) style = SOLID;
if ( pWndData->lineInfo.linestyle == DOTTED_LINE ) style = DOTTED;
if ( pWndData->lineInfo.linestyle == CENTER_LINE ) style = CENTER;
if ( pWndData->lineInfo.linestyle == DASHED_LINE ) style = DASHED;
// TODO: If user specifies a 0 pattern, create a NULL pen.
if ( pWndData->lineInfo.linestyle == USERBIT_LINE ) style = CreateUserStyle( );
// Round endcaps are default, set to square
// Use a bevel join
WaitForSingleObject(pWndData->hDCMutex, 5000);
for ( int i = 0; i < MAX_PAGES; i++ )
{
hPen = ExtCreatePen( PS_GEOMETRIC | PS_ENDCAP_SQUARE
| PS_JOIN_BEVEL | PS_USERSTYLE, // Pen Style
pWndData->lineInfo.thickness, // Pen Width
&lb, // Logical Brush
style.width, // Bytes in pattern
style.pattern ); // Line Pattern
DeletePen( (HPEN)SelectObject( pWndData->hDC[i], hPen ) );
}
ReleaseMutex(pWndData->hDCMutex);
}
// The user style might appear reversed from what you expect. With the
// original Borland graphics, the least significant bit specified the first
// pixel of the line. Thus, if you reverse the bit string, the line is
// drawn as the pixels then appear.
LinePattern CreateUserStyle( )
{
WindowData* pWndData = BGI__GetWindowDataPtr( );
int style = pWndData->lineInfo.upattern;
int zeroCount = 0; // A count of the number of leading zeros
int i = 0, j, sum = 0; // i is number of dwords, sum is a running count of bits used
LinePattern userPattern; // The pattern
style &= 0xFFFF; // Only lower 16 bits matter
if ( style == 0 )
{
userPattern.pattern[0] = 0;
userPattern.pattern[1] = 16;
userPattern.width = 2;
return userPattern;
}
// If the pattern starts with a zero, count how many and store until
// later
if ( (style & 1) == 0 )
{
for ( j = 0; !( style & 1 ); j++ ) style >>= 1;
zeroCount = j;
sum += j;
}
// See note above (in Global Variables) for dash being one pixel more,
// space being one pixel less
while( true )
{
// Get a count of the number of ones
for ( j = 0; style & 1; j++ ) style >>= 1;
userPattern.pattern[i++] = j-1; // Subtract one for dash
sum += j;
// Check if the pattern is now zero.
if ( style == 0 )
{
if ( sum != 16 )
userPattern.pattern[i++] = 16 - sum + 1; // Add one for space
break;
}
// Get a count of the number of zeros
for ( j = 0; !( style & 1 ); j++ ) style >>= 1;
userPattern.pattern[i++] = j + 1; // Add one for space
sum += j;
}
// If there were leading zeros, put them at the end
if ( zeroCount > 0 )
{
// If i is even, we ended on a space. Add the leading zeros to the back
// end count. If i is odd, we ended on a dash. Append the leading zeros.
if ( (i % 2) == 0 )
userPattern.pattern[i-1] += zeroCount;
else
userPattern.pattern[i++] = zeroCount;
}
else // If there were no leading zeros, check if we need to add a space
{
// If we ended on a dash and there are no more following zeros, put a
// zero-length space. This is necessary since the user may specify
// a style of 0xFFFF. In this case, a solid line is not created unless
// there is a zero-length space at the end.
if ( (i % 2) != 0 )
userPattern.pattern[i++] = 0;
}
// Set the with to the number of array indices used
userPattern.width = i;
return userPattern;
}
/*****************************************************************************
*
* The actual API calls are implemented below
*
*****************************************************************************/
// This function will pause the current thread for the specified number of
// milliseconds
//
void delay( int msec )
{
Sleep( msec );
}
// This function returns information about the last call to arc.
//
void getarccoords( arccoordstype *arccoords )
{
WindowData* pWndData = BGI__GetWindowDataPtr( );
*arccoords = pWndData->arcInfo;
}
// This function returns the current background color.
//
int getbkcolor( )
{
WindowData* pWndData = BGI__GetWindowDataPtr( );
return pWndData->bgColor;
}
// This function returns the current drawing color.
//
int getcolor( )
{
WindowData* pWndData = BGI__GetWindowDataPtr( );
return pWndData->drawColor;
}
// This function returns the user-defined fill pattern in the 8-byte area
// specified by pattern.
//
void getfillpattern( char *pattern )
{
WindowData* pWndData = BGI__GetWindowDataPtr( );
memcpy( pattern, pWndData->uPattern, sizeof( pWndData->uPattern ) );
}
// This function returns the current fill settings.
//
void getfillsettings( fillsettingstype *fillinfo )
{
WindowData* pWndData = BGI__GetWindowDataPtr( );
*fillinfo = pWndData->fillInfo;
}
// This function returns the current line settings.
//
void getlinesettings( linesettingstype *lineinfo )
{
WindowData* pWndData = BGI__GetWindowDataPtr( );
*lineinfo = pWndData->lineInfo;
}
// This function returns the highest color possible in the current graphics
// mode. For WinBGI, this is always WHITE (15), even though larger RGB
// colors are possible.
//
int getmaxcolor( )
{
return WHITE;
}
// This function returns the maximum x screen coordinate.
//
int getmaxx( )
{
WindowData* pWndData = BGI__GetWindowDataPtr( );
return pWndData->width - 1;
}
// This function returns the maximum y screen coordinate.
int getmaxy( )
{
WindowData* pWndData = BGI__GetWindowDataPtr( );
return pWndData->height- 1;
}
// This function returns the maximum height of a window for the current screen
int getmaxheight( )
{
int CaptionHeight = GetSystemMetrics( SM_CYCAPTION ); // Height of caption area
int yBorder = GetSystemMetrics( SM_CYFIXEDFRAME ); // Height of border
int TotalHeight = GetSystemMetrics( SM_CYSCREEN ); // Height of screen
return TotalHeight - (CaptionHeight + 2*yBorder); // Calculate max height
}
// This function returns the maximum width of a window for the current screen
int getmaxwidth( )
{
int xBorder = GetSystemMetrics( SM_CXFIXEDFRAME ); // Width of border
int TotalWidth = GetSystemMetrics( SM_CXSCREEN ); // Width of screen
return TotalWidth - (2*xBorder); // Calculate max width
}
// This function returns the total window height, including borders
int getwindowheight( )
{
WindowData* pWndData = BGI__GetWindowDataPtr( );
int CaptionHeight = GetSystemMetrics( SM_CYCAPTION ); // Height of caption area
int yBorder = GetSystemMetrics( SM_CYFIXEDFRAME ); // Height of border
return pWndData->height + CaptionHeight + 2*yBorder; // Calculate total height
}
// This function returns the total window width, including borders
int getwindowwidth( )
{
WindowData* pWndData = BGI__GetWindowDataPtr( );
int xBorder = GetSystemMetrics( SM_CXFIXEDFRAME ); // Width of border
return pWndData->width + 2*xBorder; // Calculate total width
}
// MGM: Function to convert rgb values to a color that can be
// used with any bgi functions. Numbers 0 to WHITE are the
// original bgi colors. Other colors are 0x03rrggbb.
// This used to be a macro.
int COLOR(int r, int g, int b)
{
COLORREF color = RGB(r,g,b);
int i;
for (i = 0; i <= WHITE; i++)
{
if ( color == BGI__Colors[i] )
return i;
}
return ( 0x03000000 | color );
}
int getdisplaycolor( int color )
{
int save = getpixel( 0, 0 );
int answer;
putpixel( 0, 0, color );
answer = getpixel( 0, 0 );
putpixel( 0, 0, save );
return answer;
}
int getpixel( int x, int y )
{
HDC hDC = BGI__GetWinbgiDC( );
COLORREF color = GetPixel( hDC, x, y );
BGI__ReleaseWinbgiDC( );
int i;
if ( color == CLR_INVALID )
return CLR_INVALID;
// If the color is a BGI color, return the index rather than the RGB value.
for ( i = 0; i <= WHITE; i++ )
{
if ( color == BGI__Colors[i] )
return i;
}
// If we got here, the color didn't match a BGI color. Thus, convert to
// our RGB format.
color |= 0x03000000;
return color;
}
void getviewsettings( viewporttype *viewport )
{
WindowData* pWndData = BGI__GetWindowDataPtr( );
*viewport = pWndData->viewportInfo;
}
// This function returns the x-cordinate of the current graphics position.
//
int getx( )
{
HDC hDC = BGI__GetWinbgiDC( );
POINT cp;
GetCurrentPositionEx( hDC, &cp );
BGI__ReleaseWinbgiDC( );
return cp.x;
}
// This function returns the y-cordinate of the current graphics position.
//
int gety( )
{
HDC hDC = BGI__GetWinbgiDC( );
POINT cp;
GetCurrentPositionEx( hDC, &cp );
BGI__ReleaseWinbgiDC( );
return cp.y;
}
// This function moves the current postion by dx pixels in the x direction and
// dy pixels in the y direction.
//
void moverel( int dx, int dy )
{
HDC hDC = BGI__GetWinbgiDC( );
POINT cp;
// Get the current position
GetCurrentPositionEx( hDC, &cp );
// Move to the new posotion
MoveToEx( hDC, cp.x + dx, cp.y + dy, NULL );
BGI__ReleaseWinbgiDC( );
}
// This function moves the current point to position (x,y)
//
void moveto( int x, int y )
{
HDC hDC = BGI__GetWinbgiDC( );
MoveToEx( hDC, x, y, NULL );
BGI__ReleaseWinbgiDC( );
}
void setbkcolor( int color )
{
WindowData* pWndData = BGI__GetWindowDataPtr( );
pWndData->bgColor = color;
// Convert from BGI color to RGB color
color = converttorgb( color );
WaitForSingleObject(pWndData->hDCMutex, 5000);
for ( int i = 0; i < MAX_PAGES; i++ )
SetBkColor( pWndData->hDC[i], color );
ReleaseMutex(pWndData->hDCMutex);
}
void setcolor( int color )
{
WindowData* pWndData = BGI__GetWindowDataPtr( );
// Update the color in our structure
pWndData->drawColor = color;
// Convert from BGI color to RGB color
color = converttorgb( color );
// Use that to set the text color for each page
WaitForSingleObject(pWndData->hDCMutex, 5000);
for ( int i = 0; i < MAX_PAGES; i++ )
SetTextColor( pWndData->hDC[i], color );
ReleaseMutex(pWndData->hDCMutex);
// Create the new drawing pen
CreateNewPen( );
}
void setlinestyle( int linestyle, unsigned upattern, int thickness )
{
WindowData* pWndData = BGI__GetWindowDataPtr( );
pWndData->lineInfo.linestyle = linestyle;
pWndData->lineInfo.upattern = upattern;
pWndData->lineInfo.thickness = thickness;
// Create the new drawing pen
CreateNewPen( );
}
// The user calls this function to create a brush with a pattern they create
//
void setfillpattern( char *upattern, int color )
{
WindowData* pWndData = BGI__GetWindowDataPtr( );
HBITMAP hBitmap;
HBRUSH hBrush;
unsigned short pattern[8];
int i;
// Copy the pattern to the storage for the window
memcpy( pWndData->uPattern, upattern, sizeof( pWndData->uPattern ) );
// Convert the pattern to create a brush
for ( i = 0; i < 8; i++ )
pattern[i] = (unsigned char)~upattern[i]; // Restrict to 8 bits
// Set the settings for the structure
pWndData->fillInfo.pattern = USER_FILL;
pWndData->fillInfo.color = color;
// Create the bitmap
hBitmap = CreateBitmap( 8, 8, 1, 1, pattern );
// Create a brush for each DC
WaitForSingleObject(pWndData->hDCMutex, 5000);
for ( int i = 0; i < MAX_PAGES; i++ )
{
hBrush = CreatePatternBrush( hBitmap );
// Select the new brush into the device context and delete the old one.
DeleteBrush( (HBRUSH)SelectBrush( pWndData->hDC[i], hBrush ) );
}
ReleaseMutex(pWndData->hDCMutex);
// I'm not sure if it's safe to delete the bitmap here or not, but it
// hasn't caused any problems. The material I've found just says the
// bitmap must be deleted in addition to the brush when finished.
DeleteBitmap( hBitmap );
}
// If the USER_FILL pattern is passed, nothing is changed.
//
void setfillstyle( int pattern, int color )
{
WindowData* pWndData = BGI__GetWindowDataPtr( );
HDC hDC = BGI__GetWinbgiDC( );
HBRUSH hBrush;
// Unsigned char creates a truncation for some reason.
unsigned short Slash[8] = { ~0xE0, ~0xC1, ~0x83, ~0x07, ~0x0E, ~0x1C, ~0x38, ~0x70 };
unsigned short BkSlash[8] = { ~0x07, ~0x83, ~0xC1, ~0xE0, ~0x70, ~0x38, ~0x1C, ~0x0E };
unsigned short Interleave[8] = { ~0xCC, ~0x33, ~0xCC, ~0x33, ~0xCC, ~0x33, ~0xCC, ~0x33 };
unsigned short WideDot[8] = { ~0x80, ~0x00, ~0x08, ~0x00, ~0x80, ~0x00, ~0x08, ~0x00 };
unsigned short CloseDot[8] = { ~0x88, ~0x00, ~0x22, ~0x00, ~0x88, ~0x00, ~0x22, ~0x00 };
HBITMAP hBitmap;
// Convert from BGI color to RGB color
color = converttorgb( color );
switch ( pattern )
{
case EMPTY_FILL:
hBrush = CreateSolidBrush( converttorgb( pWndData->bgColor ));
break;
case SOLID_FILL:
hBrush = CreateSolidBrush( color );
break;
case LINE_FILL:
hBrush = CreateHatchBrush( HS_HORIZONTAL, color );
break;
case LTSLASH_FILL:
hBrush = CreateHatchBrush( HS_BDIAGONAL, color );
break;
case SLASH_FILL:
// The colors of the monochrome bitmap are drawn using the text color
// and the current background color.
// TODO: We may have to set the text color in every fill function
// and then reset the text color to the user-specified text color
// after the fill-draw routines are complete.
hBitmap = CreateBitmap( 8, 8, 1, 1, Slash );
hBrush = CreatePatternBrush( hBitmap );
DeleteBitmap( hBitmap );
break;
case BKSLASH_FILL:
hBitmap = CreateBitmap( 8, 8, 1, 1, BkSlash );
hBrush = CreatePatternBrush( hBitmap );
DeleteBitmap( hBitmap );
break;
case LTBKSLASH_FILL:
hBrush = CreateHatchBrush( HS_FDIAGONAL, color );
break;
case HATCH_FILL:
hBrush = CreateHatchBrush( HS_CROSS, color );
break;
case XHATCH_FILL:
hBrush = CreateHatchBrush( HS_DIAGCROSS, color );
break;
case INTERLEAVE_FILL:
hBitmap = CreateBitmap( 8, 8, 1, 1, Interleave );
hBrush = CreatePatternBrush( hBitmap );
DeleteBitmap( hBitmap );
break;
case WIDE_DOT_FILL:
hBitmap = CreateBitmap( 8, 8, 1, 1, WideDot );
hBrush = CreatePatternBrush( hBitmap );
DeleteBitmap( hBitmap );
break;
case CLOSE_DOT_FILL:
hBitmap = CreateBitmap( 8, 8, 1, 1, CloseDot );
hBrush = CreatePatternBrush( hBitmap );
DeleteBitmap( hBitmap );
break;
case USER_FILL:
return;
break;
default:
pWndData->error_code = grError;
return;
}
// TODO: Modify this so the brush is created in every DC
pWndData->fillInfo.pattern = pattern;
pWndData->fillInfo.color = color;
// Select the new brush into the device context and delete the old one.
DeleteBrush( (HBRUSH)SelectBrush( hDC, hBrush ) );
BGI__ReleaseWinbgiDC( );
}
void setviewport( int left, int top, int right, int bottom, int clip )
{
WindowData* pWndData = BGI__GetWindowDataPtr( );
HRGN hRGN = NULL;
// Store the viewport information in the structure
pWndData->viewportInfo.left = left;
pWndData->viewportInfo.top = top;
pWndData->viewportInfo.right = right;
pWndData->viewportInfo.bottom = bottom;
pWndData->viewportInfo.clip = clip;
// If the drwaing should be clipped at the viewport boundary, create a
// clipping region
if ( clip != 0 )
hRGN = CreateRectRgn( left, top, right, bottom );
WaitForSingleObject(pWndData->hDCMutex, 5000);
for ( int i = 0; i < MAX_PAGES; i++ )
{
SelectClipRgn( pWndData->hDC[i], hRGN );
// Set the viewport origin to be the upper left corner
SetViewportOrgEx( pWndData->hDC[i], left, top, NULL );
// Move to the new origin
MoveToEx( pWndData->hDC[i], 0, 0, NULL );
}
ReleaseMutex(pWndData->hDCMutex);
// A copy of the region is used for the clipping region, so it is
// safe to delete the region (p. 369 Win32 API book)
DeleteRgn( hRGN );
}
void setwritemode( int mode )
{
HDC hDC = BGI__GetWinbgiDC( );
if ( mode == COPY_PUT )
SetROP2( hDC, R2_COPYPEN );
if ( mode == XOR_PUT )
SetROP2( hDC, R2_XORPEN );
BGI__ReleaseWinbgiDC( );
}