1This is grx249um.inf, produced by makeinfo version 4.13 from grx2.tex.
2
3INFO-DIR-SECTION Libraries
4START-INFO-DIR-ENTRY
5* GRX: (grx).                   The GRX Graphics Library.
6END-INFO-DIR-ENTRY
7
8
9File: grx249um.inf,  Node: Top,  Next: A User Manual For GRX2
10
11            GRX 2.4.9 User's Manual
12***********************
13
14A 2D graphics library for DOS, Linux, X11 and Win32
15***************************************************
16 Based on the original doc written by: Csaba Biegl on August 10, 1992
17       Updated by: Mariano Alvarez Fernandez on August 17, 2000
18                      Last update: July 10, 2012
19
20Abstract
21********
22
23*GRX* is a 2D graphics library originaly written by Csaba Biegl for DJ
24Delorie's DOS port of the GCC compiler. Now it support a big range of
25platforms, the main four are: DOS (DJGPPv2), Linux console, X11 and
26Win32 (Mingw). On DOS it supports VGA, EGA and VESA compliant cards.
27On Linux console it uses svgalib or the framebuffer. On X11 it must
28work on any X11R5 (or later). From the 2.4 version, GRX comes with a
29Win32 driver.  The framebuffer Linux console driver was new in 2.4.2.
30From 2.4.7 there is a support for x86_64 bits Linux machines and a
31support for an SDL driver on MingW and X11. On MingW and X11 it runs on
32a window with the original driver, and either full screen or on a
33window with the SDL driver.
34
35* Menu:
36
37* A User Manual For GRX2::
38
39
40File: grx249um.inf,  Node: A User Manual For GRX2,  Next: Hello world,  Prev: Top,  Up: Top
41
42GRX2 User's Manual
43******************
44
45* Menu:
46
47* Top::
48* Hello world::
49* Data types and function declarations::
50* Setting the graphics driver::
51* Setting video modes::
52* Graphics contexts::
53* Context use::
54* Color management::
55* Portable use of a few colors::
56* Graphics primitives::
57* Non-clipping graphics primitives::
58* Customized line drawing::
59* Pattern filled graphics primitives::
60* Patterned line drawing::
61* Image manipulation::
62* Text drawing::
63* Drawing in user coordinates::
64* Graphics cursors::
65* Keyboard input::
66* Mouse event handling::
67* Writing/reading PNM graphics files::
68* Writing/reading PNG graphics files::
69* Writing/reading JPEG graphics files::
70* Miscellaneous functions::
71* BGI interface::
72* Pascal interface::
73* References::
74
75
76File: grx249um.inf,  Node: Hello world,  Next: Data types and function declarations,  Prev: A User Manual For GRX2,  Up: A User Manual For GRX2
77
78Hello world
79===========
80
81The next program draws a double frame around the screen and writes
82"Hello, GRX world" centered. Then it waits after a key is pressed.
83
84     #include <string.h>
85     #include <grx20.h>
86     #include <grxkeys.h>
87
88     int main()
89     {
90       char *message = "Hello, GRX world";
91       int x, y;
92       GrTextOption grt;
93
94       GrSetMode( GR_default_graphics );
95
96       grt.txo_font = &GrDefaultFont;
97       grt.txo_fgcolor.v = GrWhite();
98       grt.txo_bgcolor.v = GrBlack();
99       grt.txo_direct = GR_TEXT_RIGHT;
100       grt.txo_xalign = GR_ALIGN_CENTER;
101       grt.txo_yalign = GR_ALIGN_CENTER;
102       grt.txo_chrtype = GR_BYTE_TEXT;
103
104       GrBox( 0,0,GrMaxX(),GrMaxY(),GrWhite() );
105       GrBox( 4,4,GrMaxX()-4,GrMaxY()-4,GrWhite() );
106
107       x = GrMaxX()/2;
108       y = GrMaxY()/2;
109       GrDrawString( message,strlen( message ),x,y,&grt );
110
111       GrKeyRead();
112
113       return 0;
114     }
115How to compile the hello world (assuming the GRX library was previously
116installed)
117       DJGPP: gcc -o hellogrx.exe hellogrx.c -lgrx20
118       Mingw: gcc -o hellogrx.exe hellogrx.c -lgrx20 -mwindows
119       X11  : gcc -o hellogrx hellogrx.c -D__XWIN__ -I/usr/X11R6/include
120              -lgrx20X -L/usr/X11R6/lib -lX11
121       Linux: gcc -o hellogrx hellogrx.c -lgrx20 -lvga
122
123       For the SDL driver:
124       Mingw: gcc -o hellogrx.exe hellogrx.c -lgrx20S -lSDL
125       X11  : gcc -o hellogrx hellogrx.c -D__XWIN__ -I/usr/X11R6/include
126              -lgrx20S -lSDL -lpthread -L/usr/X11R6/lib -lX11
127
128       For x86_64 systems add -m32 or -m64 for 32/64 bits executables
129       and replace /lib by /lib64 or /lib32 as needed
130
131
132File: grx249um.inf,  Node: Data types and function declarations,  Next: Setting the graphics driver,  Prev: Hello world,  Up: A User Manual For GRX2
133
134Data types and function declarations
135====================================
136
137All public data structures and graphics primitives meant for usage by
138the application program are declared/prototyped in the header files (in
139the 'include' sub-directory):
140
141        * grdriver.h   graphics driver format specifications
142        * grfontdv.h   format of a font when loaded into memory
143        * grx20.h      drawing-related structures and functions
144        * grxkeys.h    platform independent key definitions
145
146     User programs normally only include *include/grx20.h* and *include/grxkeys.h*
147
148
149File: grx249um.inf,  Node: Setting the graphics driver,  Next: Setting video modes,  Prev: Data types and function declarations,  Up: A User Manual For GRX2
150
151Setting the graphics driver
152===========================
153
154The graphics driver is normally set by the final user by the environment
155variable GRX20DRV, but a program can set it using:
156
157     int GrSetDriver(char *drvspec);
158
159The drvspec string has the same format as the environment variable:
160
161     <driver> gw <width> gh <height> nc <colors>
162
163Available drivers are for:
164
165     * DOS => herc, stdvga, stdega, et4000, cl5426, mach64, ati28800, s3, VESA, memory
166     * Linux => svgalib, linuxfb, memory
167     * X11 => xwin, memory
168     * Win32 => win32, memory
169     * SDL (Win32 and X11) => sdl::fs, sdl::ww, memory
170
171The xwin and win32 drivers are windowed.  The SDL driver on the same
172systems can be either fullscreen (::fs) or windowed (::ww).
173
174The optionals gw, gh and nc parameters set the desired default graphics
175mode.  Normal values for 'nc' are 2, 16, 256, 64K and 16M. The current
176driver name can be obtained from:
177
178     GrCurrentVideoDriver()->name
179
180
181File: grx249um.inf,  Node: Setting video modes,  Next: Graphics contexts,  Prev: Setting the graphics driver,  Up: A User Manual For GRX2
182
183Setting video modes
184===================
185
186Before a program can do any graphics drawing it has to configure the
187graphics driver for the desired graphics mode. It is done with the
188GrSetMode function as follows:
189
190     int GrSetMode(int which,...);
191
192On succes it returns non-zero (TRUE). The which parameter can be one of
193the following constants, declared in grx20.h:
194
195     typedef enum _GR_graphicsModes {
196       GR_80_25_text,
197       GR_default_text,
198       GR_width_height_text,
199       GR_biggest_text,
200       GR_320_200_graphics,
201       GR_default_graphics,
202       GR_width_height_graphics,
203       GR_biggest_noninterlaced_graphics,
204       GR_biggest_graphics,
205       GR_width_height_color_graphics,
206       GR_width_height_color_text,
207       GR_custom_graphics,
208       GR_width_height_bpp_graphics,
209       GR_width_height_bpp_text,
210       GR_custom_bpp_graphics,
211       GR_NC_80_25_text,
212       GR_NC_default_text,
213       GR_NC_width_height_text,
214       GR_NC_biggest_text,
215       GR_NC_320_200_graphics,
216       GR_NC_default_graphics,
217       GR_NC_width_height_graphics,
218       GR_NC_biggest_noninterlaced_graphics,
219       GR_NC_biggest_graphics,
220       GR_NC_width_height_color_graphics,
221       GR_NC_width_height_color_text,
222       GR_NC_custom_graphics,
223       GR_NC_width_height_bpp_graphics,
224       GR_NC_width_height_bpp_text,
225       GR_NC_custom_bpp_graphics,
226     } GrGraphicsMode;
227
228The GR_width_height_text and GR_width_height_graphics modes require the
229two size arguments: int width and int height.
230
231The GR_width_height_color_graphics and GR_width_height_color_text modes
232require three arguments: int width, int height and GrColor colors.
233
234The GR_width_height_bpp_graphics and GR_width_height_bpp_text modes
235require three arguments: int width, int height and int bpp (bits per
236plane instead number of colors).
237
238The GR_custom_graphics and GR_custom_bpp_graphics modes require five
239arguments: int width, int height, GrColor colors or int bpp, int vx and
240int vy.  Using this modes you can set a virtual screen of vx by vy size.
241
242A call with any other mode does not require any arguments.
243
244The GR_NC_... modes are equivalent to the GR_.. ones, but they don't
245clear the video memory.
246
247Graphics drivers can provide info of the supported graphics modes, use
248the next code skeleton to colect the data:
249
250     {
251       GrFrameMode fm;
252       const GrVideoMode *mp;
253       for(fm =GR_firstGraphicsFrameMode; fm <= GR_lastGraphicsFrameMode; fm++) {
254         mp = GrFirstVideoMode(fm);
255         while( mp != NULL ) {
256           ..
257           .. use the mp info
258           ..
259           mp = GrNextVideoMode(mp))
260         }
261       }
262     }
263
264Don't worry if you don't understand it, normal user programs don't need
265to know about FrameModes. The GrVideoMode structure has the following
266fields:
267
268     typedef struct _GR_videoMode GrVideoMode;
269
270     struct _GR_videoMode {
271       char    present;                    /* is it really available? */
272       char    bpp;                        /* log2 of # of colors */
273       short   width,height;               /* video mode geometry */
274       short   mode;                       /* BIOS mode number (if any) */
275       int     lineoffset;                 /* scan line length */
276       int     privdata;                   /* driver can use it for anything */
277       struct _GR_videoModeExt *extinfo;   /* extra info (maybe shared) */
278     };
279
280The width, height and bpp members are the useful information if you are
281interested in set modes other than the GR_default_graphics.
282
283A user-defined function can be invoked every time the video mode is
284changed (i.e. GrSetMode is called). This function should not take any
285parameters and don't return any value. It can be installed (for all
286subsequent GrSetMode calls) with the:
287
288     void GrSetModeHook(void (*hookfunc)(void));
289
290function. The current graphics mode (one of the valid mode argument
291values for GrSetMode) can be obtained with the:
292
293     GrGraphicsMode GrCurrentMode(void);
294
295function, while the type of the installed graphics adapter can be
296determined with the:
297
298     GrVideoAdapter GrAdapterType(void);
299
300function. GrAdapterType returns the type of the adapter as one of the
301following symbolic constants (defined in grx20.h):
302
303     typedef enum _GR_videoAdapters {
304       GR_UNKNOWN = (-1),     /* not known (before driver set) */
305       GR_VGA,                /* VGA adapter */
306       GR_EGA,                /* EGA adapter */
307       GR_HERC,               /* Hercules mono adapter */
308       GR_8514A,              /* 8514A or compatible */
309       GR_S3,                 /* S3 graphics accelerator */
310       GR_XWIN,               /* X11 driver */
311       GR_WIN32,              /* WIN32 driver */
312       GR_LNXFB,              /* Linux framebuffer */
313       GR_SDL,                /* SDL driver */
314       GR_MEM                 /* memory only driver */
315     } GrVideoAdapter;
316
317Note that the VESA driver return GR_VGA here.
318
319
320File: grx249um.inf,  Node: Graphics contexts,  Next: Context use,  Prev: Setting video modes,  Up: A User Manual For GRX2
321
322Graphics contexts
323=================
324
325The library supports a set of drawing regions called contexts (the
326GrContext structure). These can be in video memory or in system memory.
327Contexts in system memory always have the same memory organization as
328the video memory. When GrSetMode is called, a default context is
329created which maps to the whole graphics screen. Contexts are described
330by the GrContext data structure:
331
332     typedef struct _GR_context GrContext;
333
334     struct _GR_context {
335       struct _GR_frame    gc_frame;       /* frame buffer info */
336       struct _GR_context *gc_root;        /* context which owns frame */
337       int    gc_xmax;                     /* max X coord (width  - 1) */
338       int    gc_ymax;                     /* max Y coord (height - 1) */
339       int    gc_xoffset;                  /* X offset from root's base */
340       int    gc_yoffset;                  /* Y offset from root's base */
341       int    gc_xcliplo;                  /* low X clipping limit */
342       int    gc_ycliplo;                  /* low Y clipping limit */
343       int    gc_xcliphi;                  /* high X clipping limit */
344       int    gc_ycliphi;                  /* high Y clipping limit */
345       int    gc_usrxbase;                 /* user window min X coordinate */
346       int    gc_usrybase;                 /* user window min Y coordinate */
347       int    gc_usrwidth;                 /* user window width  */
348       int    gc_usrheight;                /* user window height */
349     # define gc_baseaddr                  gc_frame.gf_baseaddr
350     # define gc_selector                  gc_frame.gf_selector
351     # define gc_onscreen                  gc_frame.gf_onscreen
352     # define gc_memflags                  gc_frame.gf_memflags
353     # define gc_lineoffset                gc_frame.gf_lineoffset
354     # define gc_driver                    gc_frame.gf_driver
355     };
356
357The following four functions return information about the layout of and
358memory occupied by a graphics context of size width by height in the
359current graphics mode (as set up by GrSetMode):
360
361     int GrLineOffset(int width);
362     int GrNumPlanes(void);
363     long GrPlaneSize(int w,int h);
364     long GrContextSize(int w,int h);
365
366GrLineOffset always returns the offset between successive pixel rows of
367the context in bytes. GrNumPlanes returns the number of bitmap planes
368in the current graphics mode. GrContextSize calculates the total amount
369of memory needed by a context, while GrPlaneSize calculates the size of
370a bitplane in the context. The function:
371
372     GrContext *GrCreateContext(int w,int h,char far *memory[4],GrContext *where);
373
374can be used to create a new context in system memory. The NULL pointer
375is also accepted as the value of the memory and where arguments, in
376this case the library allocates the necessary amount of memory
377internally. It is a general convention in the library that functions
378returning pointers to any GRX specific data structure have a last
379argument (most of the time named where in the prototypes) which can be
380used to pass the address of the data structure which should be filled
381with the result. If this where pointer has the value of NULL, then the
382library allocates space for the data structure internally.
383
384The memory argument is really a 4 pointer array, each pointer must
385point to space to handle GrPlaneSize(w,h) bytes, really only
386GrNumPlanes() pointers must be malloced, the rest can be NULL.
387Nevertheless the normal use (see below) is
388
389     gc = GrCreateContext(w,h,NULL,NULL);
390
391so yo don't need to care about.
392
393The function:
394
395     GrContext *GrCreateSubContext(int x1,int y1,int x2,int y2,
396                                   const GrContext *parent,GrContext *where);
397
398creates a new sub-context which maps to a part of an existing context.
399The coordinate arguments (x1 through y2) are interpreted relative to
400the parent context's limits. Pixel addressing is zero-based even in
401sub-contexts, i.e. the address of the top left pixel is (0,0) even in a
402sub-context which has been mapped onto the interior of its parent
403context.
404
405Sub-contexts can be resized, but not their parents (i.e. anything
406returned by GrCreateContext or set up by GrSetMode cannot be resized -
407because this could lead to irrecoverable "loss" of drawing memory. The
408following function can be used for this purpose:
409
410     void GrResizeSubContext(GrContext *context,int x1,int y1,int x2,int y2);
411
412The current context structure is stored in a static location in the
413library.  (For efficiency reasons - it is used quite frequently, and
414this way no pointer dereferencing is necessary.) The context stores all
415relevant information about the video organization, coordinate limits,
416etc... The current context can be set with the:
417
418     void GrSetContext(const GrContext *context);
419
420function. This function will reset the current context to the full
421graphics screen if it is passed the NULL pointer as argument. The value
422of the current context can be saved into a GrContext structure pointed
423to by where using:
424
425     GrContext *GrSaveContext(GrContext *where);
426
427(Again, if where is NULL, the library allocates the space.) The next two
428functions:
429
430     const GrContext *GrCurrentContext(void);
431     const GrContext *GrScreenContext(void);
432
433return the current context and the screen context respectively.
434Contexts can be destroyed with:
435
436     void GrDestroyContext(GrContext *context);
437
438This function will free the memory occupied by the context only if it
439was allocated originally by the library. The next three functions set
440up and query the clipping limits associated with the current context:
441
442     void GrSetClipBox(int x1,int y1,int x2,int y2);
443     void GrGetClipBox(int *x1p,int *y1p,int *x2p,int *y2p);
444     void GrResetClipBox(void);
445
446GrResetClipBox sets the clipping limits to the limits of context. These
447are the limits set up initially when a context is created. There are
448three similar functions to sets/gets the clipping limits of any context:
449
450     void  GrSetClipBoxC(GrContext *c,int x1,int y1,int x2,int y2);
451     void  GrGetClipBoxC(const GrContext *c,int *x1p,int *y1p,int *x2p,int *y2p);
452     void  GrResetClipBoxC(GrContext *c);
453
454The limits of the current context can be obtained using the following
455functions:
456
457     int GrMaxX(void);
458     int GrMaxY(void);
459     int GrSizeX(void);
460     int GrSizeY(void);
461
462The Max functions return the biggest valid coordinate, while the Size
463functions return a value one higher. The limits of the graphics screen
464(regardless of the current context) can be obtained with:
465
466     int GrScreenX(void);
467     int GrScreenY(void);
468
469If you had set a virtual screen (using a custom graphics mode), the
470limits of the virtual screen can be fetched with:
471
472     int GrVirtualX(void);
473     int GrVirtualY(void);
474
475The routine:
476
477     int GrScreenIsVirtual(void);
478
479returns non zero if a virtual screen is set. The rectangle showed in
480the real screen can be set with:
481
482     int GrSetViewport(int xpos,int ypos);
483
484and the current viewport position can be obtained by:
485
486     int GrViewportX(void);
487     int GrViewportY(void);
488
489
490File: grx249um.inf,  Node: Context use,  Next: Color management,  Prev: Graphics contexts,  Up: A User Manual For GRX2
491
492Context use
493===========
494
495Here is a example of normal context use:
496
497     GrContext *grc;
498
499     if( (grc = GrCreateContext( w,h,NULL,NULL )) == NULL ){
500       ...process the error
501       }
502     else {
503       GrSetContext( grc );
504       ...do some drawing
505       ...and probably bitblt to the screen context
506       GrSetContext( NULL ); /* the screen context! */
507       GrDestroyContext( grc );
508       }
509
510But if you have a GrContext variable (not a pointer) you want to use
511(probably because is static to some routines) you can do:
512
513     static GrContext grc; /* not a pointer!! */
514
515     if( GrCreateContext( w,h,NULL,&grc )) == NULL ) {
516       ...process the error
517      }
518     else {
519       GrSetContext( &grc );
520       ...do some drawing
521       ...and probably bitblt to the screen context
522       GrSetContext( NULL ); /* the screen context! */
523       GrDestroyContext( &grc );
524       }
525
526Note that GrDestoryContext knows if grc was automatically malloced or
527not!!
528
529Only if you don't want GrCreateContext use malloc at all, you must
530allocate the memory buffers and pass it to GrCreateContext.
531
532Using GrCreateSubContext is the same, except it doesn't need the buffer,
533because it uses the parent buffer.
534
535See the *test/winclip.c* and *test/wintest.c* examples.
536
537
538File: grx249um.inf,  Node: Color management,  Next: Portable use of a few colors,  Prev: Context use,  Up: A User Manual For GRX2
539
540Color management
541================
542
543GRX defines the type GrColor for color variables. GrColor it's a 32 bits
544integer. The 8 left bits are reserved for the write mode (see below).
545The 24 bits right are the color value.
546
547The library supports two models for color management. In the 'indirect'
548(or color table) model, color values are indices to a color table. The
549color table slots will be allocated with the highest resolution
550supported by the hardware (EGA: 2 bits, VGA: 6 bits) with respect to
551the component color intensities. In the 'direct' (or RGB) model, color
552values map directly into component color intensities with
553non-overlapping bitfields of the color index representing the component
554colors.
555
556Color table model is supported until 256 color modes. The RGB model is
557supported in 256 color and up color modes.
558
559In RGB model the color index map to component color intensities depend
560on the video mode set, so it can't be assumed the component color
561bitfields (but if you are curious check the GrColorInfo global
562structure in grx20.h).
563
564After the first GrSetMode call two colors are always defined: black and
565white.  The color values of these two colors are returned by the
566functions:
567
568     GrColor GrBlack(void);
569     GrColor GrWhite(void);
570
571GrBlack() is guaranteed to be 0.
572
573The library supports five write modes (a write mode descibes the
574operation between the actual bit color and the one to be set): write,
575XOR, logical OR, logical AND and IMAGE. These can be selected with
576OR-ing the color value with one of the following constants declared in
577grx20.h :
578
579     #define GrWRITE       0UL            /* write color */
580     #define GrXOR         0x01000000UL   /* to "XOR" any color to the screen */
581     #define GrOR          0x02000000UL   /* to "OR" to the screen */
582     #define GrAND         0x03000000UL   /* to "AND" to the screen */
583     #define GrIMAGE       0x04000000UL   /* blit: write, except given color */
584
585The GrIMAGE write mode only works with the bitblt function.  By
586convention, the no-op color is obtained by combining color value 0
587(black) with the XOR operation. This no-op color has been defined in
588grx20.h as:
589
590     #define GrNOCOLOR     (GrXOR | 0)    /* GrNOCOLOR is used for "no" color */
591
592The write mode part and the color value part of a GrColor variable can
593be obtained OR-ing it with one of the following constants declared in
594grx20.h:
595
596     #define GrCVALUEMASK  0x00ffffffUL   /* color value mask */
597     #define GrCMODEMASK   0xff000000UL   /* color operation mask */
598
599The number of colors in the current graphics mode is returned by the:
600
601     GrColor GrNumColors(void);
602
603function, while the number of unused, available color can be obtained by
604calling:
605
606     GrColor GrNumFreeColors(void);
607
608Colors can be allocated with the:
609
610     GrColor GrAllocColor(int r,int g,int b);
611     GrColor GrAllocColor2(long hcolor);
612
613functions (component intensities can range from 0 to 255, hcolor must
614be in 0xRRGGBB format), or with the:
615
616     GrColor GrAllocCell(void);
617
618function. In the second case the component intensities of the returned
619color can be set with:
620
621     void GrSetColor(GrColor color,int r,int g,int b);
622
623In the color table model both Alloc functions return GrNOCOLOR if there
624are no more free colors available. In the RGB model GrNumFreeColors
625returns 0 and GrAllocCell always returns GrNOCOLOR, as colors returned
626by GrAllocCell are meant to be changed - what is not supposed to be
627done in RGB mode. Also note that GrAllocColor operates much more
628efficiently in RGB mode, and that it never returns GrNOCOLOR in this
629case.
630
631Color table entries can be freed (when not in RGB mode) by calling:
632
633     void GrFreeColor(GrColor color);
634
635The component intensities of any color can be queried using one of this
636function:
637
638     void GrQueryColor(GrColor c,int *r,int *g,int *b);
639     void GrQueryColor2(GrColor c,long *hcolor);
640
641Initially the color system is in color table (indirect) model if there
642are 256 or less colors. 256 color modes can be put into the RGB model
643by calling:
644
645     void GrSetRGBcolorMode(void);
646
647The color system can be reset (i.e. put back into color table model if
648possible, all colors freed except for black and white) by calling:
649
650     void GrResetColors(void);
651
652The function:
653
654     void GrRefreshColors(void);
655
656reloads the currently allocated color values into the video hardware.
657This function is not needed in typical applications, unless the display
658adapter is programmed directly by the application.
659
660This functions:
661
662     GrColor GrAllocColorID(int r,int g,int b);
663     GrColor GrAllocColor2ID(long hcolor);
664     void GrQueryColorID(GrColor c,int *r,int *g,int *b);
665     void GrQueryColor2ID(GrColor c,long *hcolor);
666
667are inlined versions (except if you compile GRX with GRX_SKIP_INLINES
668defined) to be used in the RGB model (in the color table model they
669call the normal routines).
670
671See the *test/rgbtest.c* and *test/colorops.c* examples.
672
673
674File: grx249um.inf,  Node: Portable use of a few colors,  Next: Graphics primitives,  Prev: Color management,  Up: A User Manual For GRX2
675
676Portable use of a few colors
677============================
678
679People that only want to use a few colors find the GRX color handling a
680bit confusing, but it gives the power to manage a lot of color deeps
681and two color models. Here are some guidelines to easily use the famous
68216 ega colors in GRX programs. We need this GRX function:
683
684     GrColor *GrAllocEgaColors(void);
685
686it returns a 16 GrColor array with the 16 ega colors alloced (really
687it's a trivial function, read the source src/setup/colorega.c). We can
688use a construction like that:
689
690First, in your C code make a global pointer, and init it after set the
691graphics mode:
692
693     GrColor *egacolors;
694     ....
695     int your_setup_function( ... )
696     {
697       ...
698       GrSetMode( ... )
699       ...
700       egacolors = GrAllocEgaColors();
701       ...
702     }
703
704Next, add this to your main include file:
705
706     extern GrColor *egacolors;
707     #define BLACK        egacolors[0]
708     #define BLUE         egacolors[1]
709     #define GREEN        egacolors[2]
710     #define CYAN         egacolors[3]
711     #define RED          egacolors[4]
712     #define MAGENTA      egacolors[5]
713     #define BROWN        egacolors[6]
714     #define LIGHTGRAY    egacolors[7]
715     #define DARKGRAY     egacolors[8]
716     #define LIGHTBLUE    egacolors[9]
717     #define LIGHTGREEN   egacolors[10]
718     #define LIGHTCYAN    egacolors[11]
719     #define LIGHTRED     egacolors[12]
720     #define LIGHTMAGENTA egacolors[13]
721     #define YELLOW       egacolors[14]
722     #define WHITE        egacolors[15]
723
724Now you can use the defined colors in your code. Note that if you are
725in color table model in a 16 color mode, you have exhausted the color
726table. Note too that this don't work to initialize static variables
727with a color, because egacolors is not initialized.
728
729
730File: grx249um.inf,  Node: Graphics primitives,  Next: Non-clipping graphics primitives,  Prev: Portable use of a few colors,  Up: A User Manual For GRX2
731
732Graphics primitives
733===================
734
735The screen, the current context or the current clip box can be cleared
736(i.e.  set to a desired background color) by using one of the following
737three functions:
738
739     void GrClearScreen(GrColor bg);
740     void GrClearContext(GrColor bg);
741     void GrClearClipBox(GrColor bg);
742
743Any context can be cleared using this function:
744     void GrClearContextC(GrContext *ctx, GrColor bg);
745
746Thanks to the special GrColor definition, you can do more than simple
747clear with this functions, by example with:
748
749     GrClearScreen( GrWhite()|GrXOR );
750
751the graphics screen is negativized, do it again and the screen is
752restored.
753
754The following line drawing graphics primitives are supported by the
755library:
756
757     void GrPlot(int x,int y,GrColor c);
758     void GrLine(int x1,int y1,int x2,int y2,GrColor c);
759     void GrHLine(int x1,int x2,int y,GrColor c);
760     void GrVLine(int x,int y1,int y2,GrColor c);
761     void GrBox(int x1,int y1,int x2,int y2,GrColor c);
762     void GrCircle(int xc,int yc,int r,GrColor c);
763     void GrEllipse(int xc,int yc,int xa,int ya,GrColor c);
764     void GrCircleArc(int xc,int yc,int r,int start,int end,int style,GrColor c);
765     void GrEllipseArc(int xc,int yc,int xa,int ya,
766                       int start,int end,int style,GrColor c);
767     void GrPolyLine(int numpts,int points[][2],GrColor c);
768     void GrPolygon(int numpts,int points[][2],GrColor c);
769
770All primitives operate on the current graphics context. The last
771argument of these functions is always the color to use for the drawing.
772The HLine and VLine primitives are for drawing horizontal and vertical
773lines. They have been included in the library because they are more
774efficient than the general line drawing provided by GrLine. The ellipse
775primitives can only draw ellipses with their major axis parallel with
776either the X or Y coordinate axis. They take the half X and Y axis
777length in the xa and ya arguments. The arc (circle and ellipse) drawing
778functions take the start and end angles in tenths of degrees (i.e.
779meaningful range: 0 ... 3600). The angles are interpreted
780counter-clockwise starting from the positive X axis. The style argument
781can be one of this defines from grx20.h:
782
783     #define GR_ARC_STYLE_OPEN       0
784     #define GR_ARC_STYLE_CLOSE1     1
785     #define GR_ARC_STYLE_CLOSE2     2
786
787GR_ARC_STYLE_OPEN draws only the arc, GR_ARC_STYLE_CLOSE1 closes the
788arc with a line between his start and end point, GR_ARC_STYLE_CLOSE1
789draws the typical cake slice. This routine:
790
791     void GrLastArcCoords(int *xs,int *ys,int *xe,int *ye,int *xc,int *yc);
792
793can be used to retrieve the start, end, and center points used by the
794last arc drawing functions.
795
796See the *test/circtest.c* and *test/arctest.c* examples.
797
798The polyline and polygon primitives take the address of an n by 2
799coordinate array. The X values should be stored in the elements with 0
800second index, and the Y values in the elements with a second index
801value of 1. Coordinate arrays passed to the polygon primitive can
802either contain or omit the closing edge of the polygon - the primitive
803will append it to the list if it is missing.
804
805See the *test/polytest.c* example.
806
807Because calculating the arc points it's a very time consuming
808operation, there are two functions to pre-calculate the points, that
809can be used next with polyline and polygon primitives:
810
811     int  GrGenerateEllipse(int xc,int yc,int xa,int ya,
812                            int points[GR_MAX_ELLIPSE_POINTS][2]);
813     int  GrGenerateEllipseArc(int xc,int yc,int xa,int ya,int start,int end,
814                               int points[GR_MAX_ELLIPSE_POINTS][2]);
815
816The following filled primitives are available:
817
818     void GrFilledBox(int x1,int y1,int x2,int y2,GrColor c);
819     void GrFramedBox(int x1,int y1,int x2,int y2,int wdt,const GrFBoxColors *c);
820     void GrFilledCircle(int xc,int yc,int r,GrColor c);
821     void GrFilledEllipse(int xc,int yc,int xa,int ya,GrColor c);
822     void GrFilledCircleArc(int xc,int yc,int r,
823                            int start,int end,int style,GrColor c);
824     void GrFilledEllipseArc(int xc,int yc,int xa,int ya,
825                             int start,int end,int style,GrColor c);
826     void GrFilledPolygon(int numpts,int points[][2],GrColor c);
827     void GrFilledConvexPolygon(int numpts,int points[][2],GrColor c);
828
829Similarly to the line drawing, all of the above primitives operate on
830the current graphics context. The GrFramedBox primitive can be used to
831draw motif-like shaded boxes and "ordinary" framed boxes as well. The
832x1 through y2 coordinates specify the interior of the box, the border
833is outside this area, wdt pixels wide. The primitive uses five
834different colors for the interior and four borders of the box which are
835specified in the GrFBoxColors structure:
836
837     typedef struct {
838       GrColor fbx_intcolor;
839       GrColor fbx_topcolor;
840       GrColor fbx_rightcolor;
841       GrColor fbx_bottomcolor;
842       GrColor fbx_leftcolor;
843     } GrFBoxColors;
844
845The GrFilledConvexPolygon primitive can be used to fill convex
846polygons. It can also be used to fill some concave polygons whose
847boundaries do not intersect any horizontal scan line more than twice.
848All other concave polygons have to be filled with the (somewhat less
849efficient) GrFilledPolygon primitive. This primitive can also be used
850to fill several disjoint non�overlapping polygons in a single operation.
851
852The function:
853
854     void GrFloodFill(int x, int y, GrColor border, GrColor c);
855
856flood-fills the area bounded by the color border using x, y like the
857starting point.
858
859Floodspill is a color replacer, replacing color A with color B.  This
860is quite useful for highlighting a selected item in a list,  or changing
861a selected color(s) in a multi colored area.
862
863     void GrFloodSpill(int x1, int y1, int x2, int y2,
864                      GrColor old_c, GrColor new_c)
865
866replaces old color with new color in the rectangle bounded by x1, y1,
867x2, y2.
868
869     void GrFloodSpillC(GrContext *ctx, int x1, int y1, int x2, int y2,
870                       GrColor old_c, GrColor new_c)
871
872as above but in the specified context.
873
874     void GrFloodSpill2(int x1, int y1, int x2, int y2,
875                       GrColor old_c1, GrColor new_c1,
876                       GrColor old_c2, GrColor new_c2)
877
878replaces 2 colors, a one stop shop for highlighting a selection in a
879list.
880
881     void GrFloodSpillC2(GrContext *ctx, int x1, int y1, int x2, int y2,
882                       GrColor old_c1, GrColor new_c1,
883                       GrColor old_c2, GrColor new_c2)
884
885as above but in the specified context.
886
887The current color value of any pixel in the current context can be
888obtained with:
889
890     GrColor GrPixel(int x,int y);
891
892and:
893
894     GrColor GrPixelC(GrContext *c,int x,int y);
895
896do the same for any context.
897
898Rectangular areas can be transferred within a context or between
899contexts by calling:
900
901     void GrBitBlt(GrContext *dest,int x,int y,GrContext *source,
902                   int x1,int y1,int x2,int y2,GrColor op);
903
904x, y is the position in the destination context, and x1, y1, x2, y2 the
905area from the source context to be transfered. The op argument should
906be one of supported color write modes (GrWRITE, GrXOR, GrOR, GrAND,
907GrIMAGE), it will control how the pixels from the source context are
908combined with the pixels in the destination context (the GrIMAGE op
909must be ored with the color value to be handled as transparent). If
910either the source or the destination context argument is the NULL
911pointer then the current context is used for that argument.
912
913See the *test/blittest.c* example.
914
915A efficient form to get/put pixels from/to a context can be achieved
916using the next functions:
917
918     const GrColor *GrGetScanline(int x1,int x2,int yy);
919     const GrColor *GrGetScanlineC(GrContext *ctx,int x1,int x2,int yy);
920     void GrPutScanline(int x1,int x2,int yy,const GrColor *c, GrColor op);
921
922The Get functions return a pointer to a static GrColor pixel array (or
923NULL if they fail) with the color values of a row (yy) segment (x1 to
924x2). GrGetScanline uses the current context. GrGestScanlineC uses the
925context ctx (that can be NULL to refer to the current context). Note
926that the output is only valid until the next GRX call.
927
928GrPutScanline puts the GrColor pixel array c on the yy row segmet
929defined by x1 to x2 in the current context using the op operation. op
930can be any of GrWRITE, GrXOR, GrOR, GrAND or GrIMAGE. Data in c must
931fit GrCVALUEMASK otherwise the results are implementation dependend. So
932you can't supply operation code with the pixel data!.
933
934
935File: grx249um.inf,  Node: Non-clipping graphics primitives,  Next: Customized line drawing,  Prev: Graphics primitives,  Up: A User Manual For GRX2
936
937Non-clipping graphics primitives
938================================
939
940There is a non-clipping version of some of the elementary primitives.
941These are somewhat more efficient than the regular versions. These are
942to be used only in situations when it is absolutely certain that no
943drawing will be performed beyond the boundaries of the current context.
944Otherwise the program will almost certainly crash! The reason for
945including these functions is that they are somewhat more efficient than
946the regular, clipping versions. ALSO NOTE: These function do not check
947for conflicts with the mouse cursor. (See the explanation about the
948mouse cursor handling later in this document.) The list of the
949supported non-clipping primitives:
950
951     void GrPlotNC(int x,int y,GrColor c);
952     void GrLineNC(int x1,int y1,int x2,int y2,GrColor c);
953     void GrHLineNC(int x1,int x2,int y,GrColor c);
954     void GrVLineNC(int x,int y1,int y2,GrColor c);
955     void GrBoxNC(int x1,int y1,int x2,int y2,GrColor c);
956     void GrFilledBoxNC(int x1,int y1,int x2,int y2,GrColor c);
957     void GrFramedBoxNC(int x1,int y1,int x2,int y2,int wdt,const GrFBoxColors *c);
958     void grbitbltNC(GrContext *dst,int x,int y,GrContext *src,
959                     int x1,int y1,int x2,int y2,GrColor op);
960     GrColor GrPixelNC(int x,int y);
961     GrColor GrPixelCNC(GrContext *c,int x,int y);
962
963
964File: grx249um.inf,  Node: Customized line drawing,  Next: Pattern filled graphics primitives,  Prev: Non-clipping graphics primitives,  Up: A User Manual For GRX2
965
966Customized line drawing
967=======================
968
969The basic line drawing graphics primitives described previously always
970draw continuous lines which are one pixel wide. There is another group
971of line drawing functions which can be used to draw wide and/or
972patterned lines. These functions have similar parameter passing
973conventions as the basic ones with one difference: instead of the color
974value a pointer to a structure of type GrLineOption has to be passed to
975them. The definition of the GrLineOption structure:
976
977     typedef struct {
978       GrColor lno_color;             /* color used to draw line */
979       int     lno_width;             /* width of the line */
980       int     lno_pattlen;           /* length of the dash pattern */
981       unsigned char *lno_dashpat;    /* draw/nodraw pattern */
982     } GrLineOption;
983
984The lno_pattlen structure element should be equal to the number of
985alternating draw - no draw section length values in the array pointed
986to by the lno_dashpat element. The dash pattern array is assumed to
987begin with a drawn section. If the pattern length is equal to zero a
988continuous line is drawn.
989
990Example, a white line 3 bits wide (thick) and pattern 6 bits draw, 4
991bits nodraw:
992
993     GrLineOption mylineop;
994     ...
995     mylineop.lno_color = GrWhite();
996     mylineop.lno_width = 3;
997     mylineop.lno_pattlen = 2;
998     mylineop.lno_dashpat = "\x06\x04";
999
1000The available custom line drawing primitives:
1001
1002     void GrCustomLine(int x1,int y1,int x2,int y2,const GrLineOption *o);
1003     void GrCustomBox(int x1,int y1,int x2,int y2,const GrLineOption *o);
1004     void GrCustomCircle(int xc,int yc,int r,const GrLineOption *o);
1005     void GrCustomEllipse(int xc,int yc,int xa,int ya,const GrLineOption *o);
1006     void GrCustomCircleArc(int xc,int yc,int r,
1007                            int start,int end,int style,const GrLineOption *o);
1008     void GrCustomEllipseArc(int xc,int yc,int xa,int ya,
1009                             int start,int end,int style,const GrLineOption *o);
1010     void GrCustomPolyLine(int numpts,int points[][2],const GrLineOption *o);
1011     void GrCustomPolygon(int numpts,int points[][2],const GrLineOption *o);
1012
1013See the *test/linetest.c* example.
1014
1015
1016File: grx249um.inf,  Node: Pattern filled graphics primitives,  Next: Patterned line drawing,  Prev: Customized line drawing,  Up: A User Manual For GRX2
1017
1018Pattern filled graphics primitives
1019==================================
1020
1021The library also supports a pattern filled version of the basic filled
1022primitives described above. These functions have similar parameter
1023passing conventions as the basic ones with one difference: instead of
1024the color value a pointer to an union of type 'GrPattern' has to be
1025passed to them. The GrPattern union can contain either a bitmap or a
1026pixmap fill pattern. The first integer slot in the union determines
1027which type it is. Bitmap fill patterns are rectangular arrays of bits,
1028each set bit representing the foreground color of the fill operation,
1029and each zero bit representing the background. Both the foreground and
1030background colors can be combined with any of the supported logical
1031operations. Bitmap fill patterns have one restriction: their width must
1032be eight pixels. Pixmap fill patterns are very similar to contexts. The
1033relevant structure declarations (from grx20.h):
1034
1035     /*
1036      * BITMAP: a mode independent way to specify a fill pattern of two
1037      *   colors. It is always 8 pixels wide (1 byte per scan line), its
1038      *   height is user-defined. SET THE TYPE FLAG TO ZERO!!!
1039      */
1040     typedef struct _GR_bitmap {
1041       int     bmp_ispixmap;          /* type flag for pattern union */
1042       int     bmp_height;            /* bitmap height */
1043       char   *bmp_data;              /* pointer to the bit pattern */
1044       GrColor bmp_fgcolor;           /* foreground color for fill */
1045       GrColor bmp_bgcolor;           /* background color for fill */
1046       int     bmp_memflags;          /* set if dynamically allocated */
1047     } GrBitmap;
1048
1049     /*
1050      * PIXMAP: a fill pattern stored in a layout identical to the video RAM
1051      *   for filling using 'bitblt'-s. It is mode dependent, typically one
1052      *   of the library functions is used to build it. KEEP THE TYPE FLAG
1053      *   NONZERO!!!
1054      */
1055     typedef struct _GR_pixmap {
1056       int     pxp_ispixmap;          /* type flag for pattern union */
1057       int     pxp_width;             /* pixmap width (in pixels)  */
1058       int     pxp_height;            /* pixmap height (in pixels) */
1059       GrColor pxp_oper;              /* bitblt mode (SET, OR, XOR, AND, IMAGE) */
1060       struct _GR_frame pxp_source;   /* source context for fill */
1061     } GrPixmap;
1062
1063     /*
1064      * Fill pattern union -- can either be a bitmap or a pixmap
1065      */
1066     typedef union _GR_pattern {
1067       int      gp_ispixmap;          /* nonzero for pixmaps */
1068       GrBitmap gp_bitmap;            /* fill bitmap */
1069       GrPixmap gp_pixmap;            /* fill pixmap */
1070     } GrPattern;
1071
1072This define group (from grx20.h) help to acces the GrPattern menbers:
1073
1074     #define gp_bmp_data                     gp_bitmap.bmp_data
1075     #define gp_bmp_height                   gp_bitmap.bmp_height
1076     #define gp_bmp_fgcolor                  gp_bitmap.bmp_fgcolor
1077     #define gp_bmp_bgcolor                  gp_bitmap.bmp_bgcolor
1078
1079     #define gp_pxp_width                    gp_pixmap.pxp_width
1080     #define gp_pxp_height                   gp_pixmap.pxp_height
1081     #define gp_pxp_oper                     gp_pixmap.pxp_oper
1082     #define gp_pxp_source                   gp_pixmap.pxp_source
1083
1084Bitmap patterns can be easily built from initialized character arrays
1085and static structures by the C compiler, thus no special support is
1086included in the library for creating them. The only action required
1087from the application program might be changing the foreground and
1088background colors as needed. Pixmap patterns are more difficult to
1089build as they replicate the layout of the video memory which changes
1090for different video modes. For this reason the library provides three
1091functions to create pixmap patterns in a mode-independent way:
1092
1093     GrPattern *GrBuildPixmap(const char *pixels,int w,int h,const GrColorTableP colors);
1094     GrPattern *GrBuildPixmapFromBits(const char *bits,int w,int h,
1095                                      GrColor fgc,GrColor bgc);
1096     GrPattern *GrConvertToPixmap(GrContext *src);
1097
1098GrBuildPixmap build a pixmap from a two dimensional (w by h) array of
1099characters. The elements in this array are used as indices into the
1100color table specified with the argument colors. (This means that
1101pixmaps created this way can use at most 256 colors.) The color table
1102pointer:
1103
1104     typedef GrColor *GrColorTableP;
1105
1106should point to an array of integers with the first element being the
1107number of colors in the table and the color values themselves starting
1108with the second element. NOTE: any color modifiers (GrXOR, GrOR, GrAND)
1109OR-ed to the elements of the color table are ignored.
1110
1111The GrBuildPixmapFromBits function builds a pixmap fill pattern from
1112bitmap data. It is useful if the width of the bitmap pattern is not
1113eight as such bitmap patterns can not be used to build a GrBitmap
1114structure.
1115
1116The GrConvertToPixmap function converts a graphics context to a pixmap
1117fill pattern. It is useful when the pattern can be created with
1118graphics drawing operations. NOTE: the pixmap pattern and the original
1119context share the drawing RAM, thus if the context is redrawn the fill
1120pattern changes as well. Fill patterns which were built by library
1121routines can be destroyed when no longer needed (i.e. the space
1122occupied by them can be freed) by calling:
1123
1124     void GrDestroyPattern(GrPattern *p);
1125
1126NOTE: when pixmap fill patterns converted from contexts are destroyed,
1127the drawing RAM is not freed. It is freed when the original context is
1128destroyed.  Fill patterns built by the application have to be destroyed
1129by the application as well (if this is needed).
1130
1131The list of supported pattern filled graphics primitives is shown
1132below. These functions are very similar to their solid filled
1133counterparts, only their last argument is different:
1134
1135     void GrPatternFilledPlot(int x,int y,GrPattern *p);
1136     void GrPatternFilledLine(int x1,int y1,int x2,int y2,GrPattern *p);
1137     void GrPatternFilledBox(int x1,int y1,int x2,int y2,GrPattern *p);
1138     void GrPatternFilledCircle(int xc,int yc,int r,GrPattern *p);
1139     void GrPatternFilledEllipse(int xc,int yc,int xa,int ya,GrPattern *p);
1140     void GrPatternFilledCircleArc(int xc,int yc,int r,int start,int end,
1141                                   int style,GrPattern *p);
1142     void GrPatternFilledEllipseArc(int xc,int yc,int xa,int ya,int start,int end,
1143                                    int style,GrPattern *p);
1144     void GrPatternFilledConvexPolygon(int numpts,int points[][2],GrPattern *p);
1145     void GrPatternFilledPolygon(int numpts,int points[][2],GrPattern *p);
1146     void GrPatternFloodFill(int x, int y, GrColor border, GrPattern *p);
1147
1148Strictly speaking the plot and line functions in the above group are not
1149filled, but they have been included here for convenience.
1150
1151
1152File: grx249um.inf,  Node: Patterned line drawing,  Next: Image manipulation,  Prev: Pattern filled graphics primitives,  Up: A User Manual For GRX2
1153
1154Patterned line drawing
1155======================
1156
1157The custom line drawing functions introduced above also have a version
1158when the drawn sections can be filled with a (pixmap or bitmap) fill
1159pattern. To achieve this these functions must be passed both a custom
1160line drawing option (GrLineOption structure) and a fill pattern
1161(GrPattern union). These two have been combined into the GrLinePattern
1162structure:
1163
1164     typedef struct {
1165       GrPattern     *lnp_pattern;    /* fill pattern */
1166       GrLineOption  *lnp_option;     /* width + dash pattern */
1167     } GrLinePattern;
1168
1169All patterned line drawing functions take a pointer to this structure
1170as their last argument. The list of available functions:
1171
1172     void GrPatternedLine(int x1,int y1,int x2,int y2,GrLinePattern *lp);
1173     void GrPatternedBox(int x1,int y1,int x2,int y2,GrLinePattern *lp);
1174     void GrPatternedCircle(int xc,int yc,int r,GrLinePattern *lp);
1175     void GrPatternedEllipse(int xc,int yc,int xa,int ya,GrLinePattern *lp);
1176     void GrPatternedCircleArc(int xc,int yc,int r,int start,int end,
1177                               int style,GrLinePattern *lp);
1178     void GrPatternedEllipseArc(int xc,int yc,int xa,int ya,int start,int end,
1179                                int style,GrLinePattern *lp);
1180     void GrPatternedPolyLine(int numpts,int points[][2],GrLinePattern *lp);
1181     void GrPatternedPolygon(int numpts,int points[][2],GrLinePattern *lp);
1182
1183
1184File: grx249um.inf,  Node: Image manipulation,  Next: Text drawing,  Prev: Patterned line drawing,  Up: A User Manual For GRX2
1185
1186Image manipulation
1187==================
1188
1189GRX defines the GrImage type like a GrPixmap synonym:
1190
1191     #define GrImage GrPixmap
1192
1193nevertheless the GrImage type enforces the image character of this
1194object, so for compatibility with future GRX versions use the next
1195functions if you need to convert between GrImage and GrPixmap objects:
1196
1197     GrImage *GrImageFromPattern(GrPattern *p);
1198     GrPattern *GrPatternFromImage(GrImage *p);
1199
1200the GrImageFromPattern function returns NULL if the GrPattern given is
1201not a GrPixmap.
1202
1203Like pixmaps patterns images are dependent of the actual video mode
1204set. So the library provides functions to create images in a
1205mode-independent way:
1206
1207     GrImage *GrImageBuild(const char *pixels,int w,int h,const GrColorTableP colors);
1208     GrImage *GrImageFromContext(GrContext *c);
1209
1210these functions work like the GrBuildPixmap and GrConvertToPixmap ones.
1211Remember: the image and the original context share the drawing RAM.
1212
1213There are a number of functions to display all or part of an image in
1214the current context:
1215
1216     void GrImageDisplay(int x,int y, GrImage *i);
1217     void GrImageDisplayExt(int x1,int y1,int x2,int y2, GrImage *i);
1218     void GrImageFilledBoxAlign(int xo,int yo,int x1,int y1,int x2,int y2,
1219                                GrImage *p);
1220     void GrImageHLineAlign(int xo,int yo,int x,int y,int width,GrImage *p);
1221     void GrImagePlotAlign(int xo,int yo,int x,int y,GrImage *p);
1222
1223GrImageDisplay display the whole image using x, y like the upper left
1224corner in the current context. GrImageDisplayExt display as much as it
1225can (repiting the image if necesary) in the rectangle defined by x1, y1
1226and x2, y2.
1227
1228GrImageFilledBoxAlign is a most general funtion (really the later two
1229call it) display as much as it can in the defined rectangle using xo,
1230yo like the align point, it is the virtual point in the destination
1231context (it doesn't need to be into the rectangle) with that the upper
1232left image corner is aligned.
1233
1234GrImageHLineAlign and GrImagePlotAlign display a row segment or a point
1235of the image at x y position using the xo, yo allign point.
1236
1237The most usefull image funtions are these:
1238
1239     GrImage *GrImageInverse(GrImage *p,int flag);
1240     GrImage *GrImageStretch(GrImage *p,int nwidth,int nheight);
1241
1242GrImageInverse creates a new image object, flipping p left-right or
1243top-down as indicated by flag that can be:
1244
1245     #define GR_IMAGE_INVERSE_LR  0x01  /* inverse left right */
1246     #define GR_IMAGE_INVERSE_TD  0x02  /* inverse top down */
1247
1248GrImageStretch creates a new image stretching p to nwidth by nheight.
1249
1250To destroy a image objet when you don't need it any more use:
1251
1252     void GrImageDestroy(GrImage *i);
1253
1254See the *test/imgtest.c* example.
1255
1256
1257File: grx249um.inf,  Node: Text drawing,  Next: Drawing in user coordinates,  Prev: Image manipulation,  Up: A User Manual For GRX2
1258
1259Text drawing
1260============
1261
1262The library supports loadable fonts. When in memory they are bit-mapped
1263(i.e.  not scalable!) fonts. A driver design allow GRX to load
1264different font formats, the last GRX release come with drivers to load
1265the GRX own font format and the BGI Borland format for all platforms
1266supported, the X11 version can load X11 fonts too.
1267
1268The GRX distribution come with a font collection in the GRX own format.
1269Some of these fonts were converted from VGA fonts. These fonts have all
1270256 characters from the PC-437 codepage. Some additional fonts were
1271converted from fonts in the MIT X11 distribution. Most of these are
1272ISO-8859-1 coded. Fonts also have family names. The following font
1273families are included:
1274
1275     Font file name       Family  Description
1276     pc<W>x<H>[t].fnt     pc      VGA font, fixed
1277     xm<W>x<H>[b][i].fnt  X_misc  X11, fixed, miscellaneous group
1278     char<H>[b][i].fnt    char    X11, proportional, charter family
1279     cour<H>[b][i].fnt    cour    X11, fixed, courier
1280     helve<H>[b][i].fnt   helve   X11, proportional, helvetica
1281     lucb<H>[b][i].fnt    lucb    X11, proportional, lucida bright
1282     lucs<H>[b][i].fnt    lucs    X11, proportional, lucida sans serif
1283     luct<H>[b][i].fnt    luct    X11, fixed, lucida typewriter
1284     ncen<H>[b][i].fnt    ncen    X11, proportional, new century schoolbook
1285     symb<H>.fnt          symbol  X11, proportional, greek letters, symbols
1286     tms<H>[b][i].fnt     times   X11, proportional, times
1287
1288In the font names <W> means the font width, <H> the font height. Many
1289font families have bold and/or italic variants. The files containing
1290these fonts contain a 'b' and/or 'i' character in their name just
1291before the extension.  Additionally, the strings "_bold" and/or "_ital"
1292are appended to the font family names. Some of the pc VGA fonts come in
1293thin formats also, these are denoted by a 't' in their file names and
1294the string "_thin" in their family names.
1295
1296The GrFont structure hold a font in memory. A number of 'pc' fonts are
1297built-in to the library and don't need to be loaded:
1298
1299     extern  GrFont          GrFont_PC6x8;
1300     extern  GrFont          GrFont_PC8x8;
1301     extern  GrFont          GrFont_PC8x14;
1302     extern  GrFont          GrFont_PC8x16;
1303
1304Other fonts must be loaded with the GrLoadFont function. If the font
1305file name starts with any path separator character or character
1306sequence (':', '/' or '\') then it is loaded from the specified
1307directory, otherwise the library try load the font first from the
1308current directory and next from the default font path.  The font path
1309can be set up with the GrSetFontPath function. If the font path is not
1310set then the value of the 'GRXFONT' environment variable is used as the
1311font path. If GrLoadFont is called again with the name of an already
1312loaded font then it will return a pointer to the result of the first
1313loading. Font loading routines return NULL if the font was not found.
1314When not needed any more, fonts can be unloaded (i.e. the storage
1315occupied by them freed) by calling GrUnloadFont.
1316
1317The prototype declarations for these functions:
1318
1319     GrFont *GrLoadFont(char *name);
1320     void GrUnloadFont(GrFont *font);
1321     void GrSetFontPath(char *path_list);
1322
1323Using these functions:
1324
1325     GrFont *GrLoadConvertedFont(char *name,int cvt,int w,int h,
1326                                 int minch,int maxch);
1327     GrFont *GrBuildConvertedFont(const GrFont *from,int cvt,int w,int h,
1328                                  int minch,int maxch);
1329
1330a new font can be generated from a file font or a font in memory, the
1331'cvt' argument direct the conversion or-ing the desired operations from
1332these defines:
1333
1334     /*
1335      * Font conversion flags for 'GrLoadConvertedFont'. OR them as desired.
1336      */
1337     #define GR_FONTCVT_NONE         0     /* no conversion */
1338     #define GR_FONTCVT_SKIPCHARS    1     /* load only selected characters */
1339     #define GR_FONTCVT_RESIZE       2     /* resize the font */
1340     #define GR_FONTCVT_ITALICIZE    4     /* tilt font for "italic" look */
1341     #define GR_FONTCVT_BOLDIFY      8     /* make a "bold"(er) font  */
1342     #define GR_FONTCVT_FIXIFY       16    /* convert prop. font to fixed wdt */
1343     #define GR_FONTCVT_PROPORTION   32    /* convert fixed font to prop. wdt */
1344
1345GR_FONTCVT_SKIPCHARS needs 'minch' and 'maxch' arguments.
1346
1347GR_FONTCVT_RESIZE needs 'w' and 'h' arguments.
1348
1349The function:
1350
1351     void GrDumpFnaFont(const GrFont *f, char *fileName);
1352
1353writes a font to an ascii font file, so it can be quickly edited with a
1354text editor. For a description of the ascii font format, see the
1355fna.txt file.
1356
1357The function:
1358
1359     void GrDumpFont(const GrFont *f,char *CsymbolName,char *fileName);
1360
1361writes a font to a C source code file, so it can be compiled and linked
1362with a user program. GrDumpFont would not normally be used in a release
1363program because its purpose is to produce source code. When the source
1364code is compiled and linked into a program distributing the font file
1365with the program in not necessary, avoiding the possibility of the font
1366file being deleted or corrupted.
1367
1368You can use the premade fnt2c.c program (see the source, it's so
1369simple) to dump a selected font to source code, by example:
1370
1371     fnt2c helv15 myhelv15 myhelv15.c
1372
1373Next, if this line is included in your main include file:
1374
1375     extern GrFont myhelv15
1376
1377and "myhelv15.c" compiled and linked with your project, you can use
1378'myhelv15' in every place a GrFont is required.
1379
1380This simple function:
1381
1382     void GrTextXY(int x,int y,char *text,GrColor fg,GrColor bg);
1383
1384draw text in the current context in the standard direction, using the
1385GrDefaultFont (mapped in the grx20.h file to the GrFont_PC8x14 font)
1386with x, y like the upper left corner and the foreground and background
1387colors given (note that bg equal to GrNOCOLOR make the background
1388transparent).
1389
1390For other functions the GrTextOption structure specifies how to draw a
1391character string:
1392
1393     typedef struct _GR_textOption {      /* text drawing option structure */
1394       struct _GR_font     *txo_font;      /* font to be used */
1395       union  _GR_textColor txo_fgcolor;   /* foreground color */
1396       union  _GR_textColor txo_bgcolor;   /* background color */
1397       char    txo_chrtype;                /* character type (see above) */
1398       char    txo_direct;                 /* direction (see above) */
1399       char    txo_xalign;                 /* X alignment (see above) */
1400       char    txo_yalign;                 /* Y alignment (see above) */
1401     } GrTextOption;
1402
1403     typedef union _GR_textColor {        /* text color union */
1404       GrColor       v;                    /* color value for "direct" text */
1405       GrColorTableP p;                    /* color table for attribute text */
1406     } GrTextColor;
1407
1408The text can be rotated in increments of 90 degrees (txo_direct),
1409alignments can be set in both directions (txo_xalign and txo_yalign),
1410and separate fore and background colors can be specified. The accepted
1411text direction values:
1412
1413     #define GR_TEXT_RIGHT           0       /* normal */
1414     #define GR_TEXT_DOWN            1       /* downward */
1415     #define GR_TEXT_LEFT            2       /* upside down, right to left */
1416     #define GR_TEXT_UP              3       /* upward */
1417     #define GR_TEXT_DEFAULT         GR_TEXT_RIGHT
1418
1419The accepted horizontal and vertical alignment option values:
1420
1421     #define GR_ALIGN_LEFT           0       /* X only */
1422     #define GR_ALIGN_TOP            0       /* Y only */
1423     #define GR_ALIGN_CENTER         1       /* X, Y   */
1424     #define GR_ALIGN_RIGHT          2       /* X only */
1425     #define GR_ALIGN_BOTTOM         2       /* Y only */
1426     #define GR_ALIGN_BASELINE       3       /* Y only */
1427     #define GR_ALIGN_DEFAULT        GR_ALIGN_LEFT
1428
1429Text strings can be of three different types: one character per byte
1430(i.e. the usual C character string, this is the default), one character
1431per 16-bit word (suitable for fonts with a large number of characters),
1432and a PC-style character-attribute pair. In the last case the
1433GrTextOption structure must contain a pointer to a color table of size
143416 (fg color bits in attrib) or 8 (bg color bits). (The color table
1435format is explained in more detail in the previous section explaining
1436the methods to build fill patterns.) The supported text types:
1437
1438     #define GR_BYTE_TEXT            0       /* one byte per character */
1439     #define GR_WORD_TEXT            1       /* two bytes per character */
1440     #define GR_ATTR_TEXT            2       /* chr w/ PC style attribute byte */
1441
1442The PC-style attribute text uses the same layout (first byte: character,
1443second: attributes) and bitfields as the text mode screen on the PC.
1444The only difference is that the 'blink' bit is not supported (it would
1445be very time consuming - the PC text mode does it with hardware
1446support). This bit is used instead to control the underlined display of
1447characters. For convenience the following attribute manipulation macros
1448have been declared in grx20.h:
1449
1450     #define GR_BUILD_ATTR(fg,bg,ul) \
1451             (((fg) & 15) | (((bg) & 7) << 4) | ((ul) ? 128 : 0))
1452     #define GR_ATTR_FGCOLOR(attr)   (((attr)     ) &  15)
1453     #define GR_ATTR_BGCOLOR(attr)   (((attr) >> 4) &   7)
1454     #define GR_ATTR_UNDERLINE(attr) (((attr)     ) & 128)
1455
1456Text strings of the types GR_BYTE_TEXT and GR_WORD_TEXT can also be
1457drawn underlined. This is controlled by OR-ing the constant
1458GR_UNDERLINE_TEXT to the foreground color value:
1459
1460     #define GR_UNDERLINE_TEXT       (GrXOR << 4)
1461
1462After the application initializes a text option structure with the
1463desired values it can call one of the following two text drawing
1464functions:
1465
1466     void GrDrawChar(int chr,int x,int y,const GrTextOption *opt);
1467     void GrDrawString(void *text,int length,int x,int y,const GrTextOption *opt);
1468
1469NOTE: text drawing is fastest when it is drawn in the 'normal'
1470direction, and the character does not have to be clipped. It this case
1471the library can use the appropriate low-level video RAM access routine,
1472while in any other case the text is drawn pixel-by-pixel by the
1473higher-level code.
1474
1475There are pattern filed versions too:
1476
1477     void GrPatternDrawChar(int chr,int x,int y,const GrTextOption *opt,GrPattern *p);
1478     void GrPatternDrawString(void *text,int length,int x,int y,const GrTextOption *opt,
1479                              GrPattern *p);
1480     void GrPatternDrawStringExt(void *text,int length,int x,int y,
1481                                 const GrTextOption *opt,GrPattern *p);
1482
1483The size of a font, a character or a text string can be obtained by
1484calling one of the following functions. These functions also take into
1485consideration the text direction specified in the text option structure
1486passed to them.
1487
1488     int  GrFontCharPresent(const GrFont *font,int chr);
1489     int  GrFontCharWidth(const GrFont *font,int chr);
1490     int  GrFontCharHeight(const GrFont *font,int chr);
1491     int  GrFontCharBmpRowSize(const GrFont *font,int chr);
1492     int  GrFontCharBitmapSize(const GrFont *font,int chr);
1493     int  GrFontStringWidth(const GrFont *font,void *text,int len,int type);
1494     int  GrFontStringHeight(const GrFont *font,void *text,int len,int type);
1495     int  GrProportionalTextWidth(const GrFont *font,void *text,int len,int type);
1496     int  GrCharWidth(int chr,const GrTextOption *opt);
1497     int  GrCharHeight(int chr,const GrTextOption *opt);
1498     void GrCharSize(int chr,const GrTextOption *opt,int *w,int *h);
1499     int  GrStringWidth(void *text,int length,const GrTextOption *opt);
1500     int  GrStringHeight(void *text,int length,const GrTextOption *opt);
1501     void GrStringSize(void *text,int length,const GrTextOption *opt,int *w,int *h);
1502
1503The GrTextRegion structure and its associated functions can be used to
1504implement a fast (as much as possible in graphics modes) rectangular
1505text window using a fixed font. Clipping for such windows is done in
1506character size increments instead of pixels (i.e. no partial characters
1507are drawn). Only fixed fonts can be used in their natural size.
1508GrDumpText will cache the code of the drawn characters in the buffer
1509pointed to by the 'backup' slot (if it is non-NULL) and will draw a
1510character only if the previously drawn character in that grid element
1511is different.
1512
1513This can speed up text scrolling significantly in graphics modes. The
1514supported text types are the same as above.
1515
1516     typedef struct {                     /* fixed font text window desc. */
1517       struct _GR_font     *txr_font;      /* font to be used */
1518       union  _GR_textColor txr_fgcolor;   /* foreground color */
1519       union  _GR_textColor txr_bgcolor;   /* background color */
1520       void   *txr_buffer;                 /* pointer to text buffer */
1521       void   *txr_backup;                 /* optional backup buffer */
1522       int     txr_width;                  /* width of area in chars */
1523       int     txr_height;                 /* height of area in chars */
1524       int     txr_lineoffset;             /* offset in buffer(s) between rows */
1525       int     txr_xpos;                   /* upper left corner X coordinate */
1526       int     txr_ypos;                   /* upper left corner Y coordinate */
1527       char    txr_chrtype;                /* character type (see above) */
1528     } GrTextRegion;
1529
1530     void GrDumpChar(int chr,int col,int row,const GrTextRegion *r);
1531     void GrDumpText(int col,int row,int wdt,int hgt,const GrTextRegion *r);
1532     void GrDumpTextRegion(const GrTextRegion *r);
1533
1534The GrDumpTextRegion function outputs the whole text region, while
1535GrDumpText draws only a user-specified part of it. GrDumpChar updates
1536the character in the buffer at the specified location with the new
1537character passed to it as argument and then draws the new character on
1538the screen as well. With these functions you can simulate a text mode
1539window, write chars directly to the txr_buffer and call
1540GrDumpTextRegion when you want to update the window (or GrDumpText if
1541you know the area to update is small).
1542
1543See the *test/fonttest.c* example.
1544
1545
1546File: grx249um.inf,  Node: Drawing in user coordinates,  Next: Graphics cursors,  Prev: Text drawing,  Up: A User Manual For GRX2
1547
1548Drawing in user coordinates
1549===========================
1550
1551There is a second set of the graphics primitives which operates in user
1552coordinates. Every context has a user to screen coordinate mapping
1553associated with it. An application specifies the user window by calling
1554the GrSetUserWindow function.
1555
1556     void GrSetUserWindow(int x1,int y1,int x2,int y2);
1557
1558A call to this function it in fact specifies the virtual coordinate
1559limits which will be mapped onto the current context regardless of the
1560size of the context. For example, the call:
1561
1562     GrSetUserWindow(0,0,11999,8999);
1563
1564tells the library that the program will perform its drawing operations
1565in a coordinate system X:0...11999 (width = 12000) and Y:0...8999
1566(height = 9000).  This coordinate range will be mapped onto the total
1567area of the current context.  The virtual coordinate system can also be
1568shifted. For example:
1569
1570     GrSetUserWindow(5000,2000,16999,10999);
1571
1572The user coordinates can even be used to turn the usual left-handed
1573coordinate system (0:0 corresponds to the upper left corner) to a right
1574handed one (0:0 corresponds to the bottom left corner) by calling:
1575
1576     GrSetUserWindow(0,8999,11999,0);
1577
1578The library also provides three utility functions for the query of the
1579current user coordinate limits and for converting user coordinates to
1580screen coordinates and vice versa.
1581
1582     void GrGetUserWindow(int *x1,int *y1,int *x2,int *y2);
1583     void GrGetScreenCoord(int *x,int *y);
1584     void GrGetUserCoord(int *x,int *y);
1585
1586If an application wants to take advantage of the user to screen
1587coordinate mapping it has to use the user coordinate version of the
1588graphics primitives.  These have exactly the same parameter passing
1589conventions as their screen coordinate counterparts. NOTE: the user
1590coordinate system is not initialized by the library! The application
1591has to set up its coordinate mapping before calling any of the use
1592coordinate drawing functions - otherwise the program will almost
1593certainly exit (in a quite ungraceful fashion) with a 'division by
1594zero' error.  The list of supported user coordinate drawing functions:
1595
1596     void GrUsrPlot(int x,int y,GrColor c);
1597     void GrUsrLine(int x1,int y1,int x2,int y2,GrColor c);
1598     void GrUsrHLine(int x1,int x2,int y,GrColor c);
1599     void GrUsrVLine(int x,int y1,int y2,GrColor c);
1600     void GrUsrBox(int x1,int y1,int x2,int y2,GrColor c);
1601     void GrUsrFilledBox(int x1,int y1,int x2,int y2,GrColor c);
1602     void GrUsrFramedBox(int x1,int y1,int x2,int y2,int wdt,GrFBoxColors *c);
1603     void GrUsrCircle(int xc,int yc,int r,GrColor c);
1604     void GrUsrEllipse(int xc,int yc,int xa,int ya,GrColor c);
1605     void GrUsrCircleArc(int xc,int yc,int r,int start,int end,
1606                         int style,GrColor c);
1607     void GrUsrEllipseArc(int xc,int yc,int xa,int ya,int start,int end,
1608                          int style,GrColor c);
1609     void GrUsrFilledCircle(int xc,int yc,int r,GrColor c);
1610     void GrUsrFilledEllipse(int xc,int yc,int xa,int ya,GrColor c);
1611     void GrUsrFilledCircleArc(int xc,int yc,int r,int start,int end,
1612                               int style,GrColor c);
1613     void GrUsrFilledEllipseArc(int xc,int yc,int xa,int ya,int start,int end,
1614                                int style,GrColor c);
1615     void GrUsrPolyLine(int numpts,int points[][2],GrColor c);
1616     void GrUsrPolygon(int numpts,int points[][2],GrColor c);
1617     void GrUsrFilledConvexPolygon(int numpts,int points[][2],GrColor c);
1618     void GrUsrFilledPolygon(int numpts,int points[][2],GrColor c);
1619     void GrUsrFloodFill(int x, int y, GrColor border, GrColor c);
1620     GrColor GrUsrPixel(int x,int y);
1621     GrColor GrUsrPixelC(GrContext *c,int x,int y);
1622     void GrUsrCustomLine(int x1,int y1,int x2,int y2,const GrLineOption *o);
1623     void GrUsrCustomBox(int x1,int y1,int x2,int y2,const GrLineOption *o);
1624     void GrUsrCustomCircle(int xc,int yc,int r,const GrLineOption *o);
1625     void GrUsrCustomEllipse(int xc,int yc,int xa,int ya,const GrLineOption *o);
1626     void GrUsrCustomCircleArc(int xc,int yc,int r,int start,int end,
1627                               int style,const GrLineOption *o);
1628     void GrUsrCustomEllipseArc(int xc,int yc,int xa,int ya,int start,int end,
1629                                int style,const GrLineOption *o);
1630     void GrUsrCustomPolyLine(int numpts,int points[][2],const GrLineOption *o);
1631     void GrUsrCustomPolygon(int numpts,int points[][2],const GrLineOption *o);
1632     void GrUsrPatternedLine(int x1,int y1,int x2,int y2,GrLinePattern *lp);
1633     void GrUsrPatternedBox(int x1,int y1,int x2,int y2,GrLinePattern *lp);
1634     void GrUsrPatternedCircle(int xc,int yc,int r,GrLinePattern *lp);
1635     void GrUsrPatternedEllipse(int xc,int yc,int xa,int ya,GrLinePattern *lp);
1636     void GrUsrPatternedCircleArc(int xc,int yc,int r,int start,int end,
1637                                  int style,GrLinePattern *lp);
1638     void GrUsrPatternedEllipseArc(int xc,int yc,int xa,int ya,int start,int end,
1639                                   int style,GrLinePattern *lp);
1640     void GrUsrPatternedPolyLine(int numpts,int points[][2],GrLinePattern *lp);
1641     void GrUsrPatternedPolygon(int numpts,int points[][2],GrLinePattern *lp);
1642     void GrUsrPatternFilledPlot(int x,int y,GrPattern *p);
1643     void GrUsrPatternFilledLine(int x1,int y1,int x2,int y2,GrPattern *p);
1644     void GrUsrPatternFilledBox(int x1,int y1,int x2,int y2,GrPattern *p);
1645     void GrUsrPatternFilledCircle(int xc,int yc,int r,GrPattern *p);
1646     void GrUsrPatternFilledEllipse(int xc,int yc,int xa,int ya,GrPattern *p);
1647     void GrUsrPatternFilledCircleArc(int xc,int yc,int r,int start,int end,int style,GrPattern *p);
1648     void GrUsrPatternFilledEllipseArc(int xc,int yc,int xa,int ya,int start,int end,int style,GrPattern *p);
1649     void GrUsrPatternFilledConvexPolygon(int numpts,int points[][2],GrPattern *p);
1650     void GrUsrPatternFilledPolygon(int numpts,int points[][2],GrPattern *p);
1651     void GrUsrPatternFloodFill(int x, int y, GrColor border, GrPattern *p);
1652     void GrUsrDrawChar(int chr,int x,int y,const GrTextOption *opt);
1653     void GrUsrDrawString(char *text,int length,int x,int y,const GrTextOption *opt);
1654     void GrUsrTextXY(int x,int y,char *text,GrColor fg,GrColor bg);
1655
1656
1657File: grx249um.inf,  Node: Graphics cursors,  Next: Keyboard input,  Prev: Drawing in user coordinates,  Up: A User Manual For GRX2
1658
1659Graphics cursors
1660================
1661
1662The library provides support for the creation and usage of an unlimited
1663number of graphics cursors. An application can use these cursors for
1664any purpose.  Cursors always save the area they occupy before they are
1665drawn. When moved or erased they restore this area. As a general rule
1666of thumb, an application should erase a cursor before making changes to
1667an area it occupies and redraw the cursor after finishing the drawing.
1668Cursors are created with the GrBuildCursor function:
1669
1670     GrCursor *GrBuildCursor(char far *pixels,int pitch,int w,int h,
1671                             int xo,int yo,const GrColorTableP c);
1672
1673The pixels, w (=width), h (=height) and c (= color table) arguments are
1674similar to the arguments of the pixmap building library function
1675GrBuildPixmap (see that paragraph for a more detailed explanation.),
1676but with two differences.  First, is not assumed that the pixels data
1677is w x h sized, the pitch argument set the offset between rows. Second,
1678the pixmap data is interpreted slightly differently, any pixel with
1679value zero is taken as a "transparent" pixel, i.e.  the background will
1680show through the cursor pattern at that pixel. A pixmap data byte with
1681value = 1 will refer to the first color in the table, and so on.
1682
1683The xo (= X offset) and yo (= Y offset) arguments specify the position
1684(from the top left corner of the cursor pattern) of the cursor's "hot
1685point".
1686
1687The GrCursor data structure:
1688
1689     typedef struct _GR_cursor {
1690       struct _GR_context work;            /* work areas (4) */
1691       int     xcord,ycord;                /* cursor position on screen */
1692       int     xsize,ysize;                /* cursor size */
1693       int     xoffs,yoffs;                /* LU corner to hot point offset */
1694       int     xwork,ywork;                /* save/work area sizes */
1695       int     xwpos,ywpos;                /* save/work area position on screen */
1696       int     displayed;                  /* set if displayed */
1697     } GrCursor;
1698
1699is typically not used (i.e. read or changed) by the application
1700program, it should just pass pointers to these structures to the
1701appropriate library functions. Other cursor manipulation functions:
1702
1703     void GrDisplayCursor(GrCursor *cursor);
1704     void GrEraseCursor(GrCursor *cursor);
1705     void GrMoveCursor(GrCursor *cursor,int x,int y);
1706     void GrDestroyCursor(GrCursor *cursor);
1707
1708See the *test/curstest.c* example.
1709
1710
1711File: grx249um.inf,  Node: Keyboard input,  Next: Mouse event handling,  Prev: Graphics cursors,  Up: A User Manual For GRX2
1712
1713Keyboard input
1714==============
1715
1716GRX can handle platform independant key input. The file grxkeys.h
1717defines the keys to be used in the user's program. This is an extract:
1718
1719     #define GrKey_Control_A            0x0001
1720     #define GrKey_Control_B            0x0002
1721     #define GrKey_Control_C            0x0003
1722     ...
1723     #define GrKey_A                    0x0041
1724     #define GrKey_B                    0x0042
1725     #define GrKey_C                    0x0043
1726     ...
1727     #define GrKey_F1                   0x013b
1728     #define GrKey_F2                   0x013c
1729     #define GrKey_F3                   0x013d
1730     ...
1731     #define GrKey_Alt_F1               0x0168
1732     #define GrKey_Alt_F2               0x0169
1733     #define GrKey_Alt_F3               0x016a
1734
1735But you can be confident that the standard ASCII is right maped.  The
1736GrKeyType type is defined to store keycodes:
1737
1738     typedef unsigned short GrKeyType;
1739
1740This function:
1741
1742     int GrKeyPressed(void);
1743
1744returns non zero if there are any keycode waiting, that can be read
1745with:
1746
1747     GrKeyType GrKeyRead(void);
1748
1749The function:
1750
1751     int GrKeyStat(void);
1752
1753returns a keyboard status word, or-ing it with the next defines it can
1754be known the status of some special keys:
1755
1756     #define GR_KB_RIGHTSHIFT    0x01      /* right shift key depressed */
1757     #define GR_KB_LEFTSHIFT     0x02      /* left shift key depressed */
1758     #define GR_KB_CTRL          0x04      /* CTRL depressed */
1759     #define GR_KB_ALT           0x08      /* ALT depressed */
1760     #define GR_KB_SCROLLOCK     0x10      /* SCROLL LOCK active */
1761     #define GR_KB_NUMLOCK       0x20      /* NUM LOCK active */
1762     #define GR_KB_CAPSLOCK      0x40      /* CAPS LOCK active */
1763     #define GR_KB_INSERT        0x80      /* INSERT state active */
1764     #define GR_KB_SHIFT         (GR_KB_LEFTSHIFT | GR_KB_RIGHTSHIFT)
1765
1766See the *test/keys.c* example.
1767
1768
1769File: grx249um.inf,  Node: Mouse event handling,  Next: Writing/reading PNM graphics files,  Prev: Keyboard input,  Up: A User Manual For GRX2
1770
1771Mouse event handling
1772====================
1773
1774All mouse services need the presence of a mouse. An application can test
1775whether a mouse is available by calling the function:
1776
1777     int  GrMouseDetect(void);
1778
1779which will return zero if no mouse (or mouse driver) is present,
1780non-zero otherwise. The mouse must be initialized by calling one (and
1781only one) of these functions:
1782
1783     void GrMouseInit(void);
1784     void GrMouseInitN(int queue_size);
1785
1786GrMouseInit sets a event queue (see below) size to GR_M_QUEU_SIZE
1787(128). A user supply event queue size can be set calling GrMouseInitN
1788instead.
1789
1790It is a good practice to call GrMouseUnInit before exiting the program.
1791This will restore any interrupt vectors hooked by the program to their
1792original values.
1793
1794     void GrMouseUnInit(void);
1795
1796The mouse can be controlled with the following functions:
1797
1798     void GrMouseSetSpeed(int spmult,int spdiv);
1799     void GrMouseSetAccel(int thresh,int accel);
1800     void GrMouseSetLimits(int x1,int y1,int x2,int y2);
1801     void GrMouseGetLimits(int *x1,int *y1,int *x2,int *y2);
1802     void GrMouseWarp(int x,int y);
1803
1804The library calculates the mouse position only from the mouse mickey
1805counters.  (To avoid the limit and 'rounding to the next multiple of
1806eight' problem with some mouse driver when it finds itself in a
1807graphics mode unknown to it.) The parameters to the GrMouseSetSpeed
1808function specify how coordinate changes are obtained from mickey
1809counter changes, multipling by spmult and dividing by spdiv. In high
1810resolution graphics modes the value of one just works fine, in low
1811resolution modes (320x200 or similar) it is best set the spdiv to two or
1812three. (Of course, it also depends on the sensitivity the mouse.) The
1813GrMouseSetAccel function is used to control the ballistic effect: if a
1814mouse coordinate changes between two samplings by more than the thresh
1815parameter, the change is multiplied by the accel parameter. NOTE: some
1816mouse drivers perform similar calculations before reporting the
1817coordinates in mickeys. In this case the acceleration done by the
1818library will be additional to the one already performed by the mouse
1819driver. The limits of the mouse movement can be set (passed limits will
1820be clipped to the screen) with GrMouseSetLimits (default is the whole
1821screen) and the current limits can be obtained with GrMouseGetLimits.
1822GrMouseWarp sets the mouse cursor to the specified position.
1823
1824As typical mouse drivers do not know how to draw mouse cursors in high
1825resolution graphics modes, the mouse cursor is drawn by the library.
1826The mouse cursor can be set with:
1827
1828     void GrMouseSetCursor(GrCursor *cursor);
1829     void GrMouseSetColors(GrColor fg,GrColor bg);
1830
1831GrMouseSetColors uses an internal arrow pattern, the color fg will be
1832used as the interior of it and bg will be the border. The current mouse
1833cursor can be obtained with:
1834
1835     GrCursor *GrMouseGetCursor(void);
1836
1837The mouse cursor can be displayed/erased with:
1838
1839     void GrMouseDisplayCursor(void);
1840     void GrMouseEraseCursor(void);
1841
1842The mouse cursor can be left permanently displayed. All graphics
1843primitives except for the few non-clipping functions check for
1844conflicts with the mouse cursor and erase it before the drawing if
1845necessary. Of course, it may be more efficient to erase the cursor
1846manually before a long drawing sequence and redraw it after completion.
1847The library provides an alternative pair of calls for this purpose
1848which will erase the cursor only if it interferes with the drawing:
1849
1850     int  GrMouseBlock(GrContext *c,int x1,int y1,int x2,int y2);
1851     void GrMouseUnBlock(int return_value_from_GrMouseBlock);
1852
1853GrMouseBlock should be passed the context in which the drawing will
1854take place (the usual convention of NULL meaning the current context is
1855supported) and the limits of the affected area. It will erase the
1856cursor only if it interferes with the drawing. When the drawing is
1857finished GrMouseUnBlock must be called with the argument returned by
1858GrMouseBlock.
1859
1860The status of the mouse cursor can be obtained with calling
1861GrMouseCursorIsDisplayed. This function will return non-zero if the
1862cursor is displayed, zero if it is erased.
1863
1864     int  GrMouseCursorIsDisplayed(void);
1865
1866The library supports (beside the simple cursor drawing) three types of
1867"rubberband" attached to the mouse cursor. The GrMouseSetCursorMode
1868function is used to select the cursor drawing mode.
1869
1870     void GrMouseSetCursorMode(int mode,...);
1871
1872The parameter mode can have the following values:
1873
1874     #define GR_M_CUR_NORMAL   0    /* MOUSE CURSOR modes: just the cursor */
1875     #define GR_M_CUR_RUBBER   1    /* rect. rubber band (XOR-d to the screen) */
1876     #define GR_M_CUR_LINE     2    /* line attached to the cursor */
1877     #define GR_M_CUR_BOX      3    /* rectangular box dragged by the cursor */
1878
1879GrMouseSetCursorMode takes different parameters depending on the cursor
1880drawing mode selected. The accepted call formats are:
1881
1882     GrMouseSetCursorMode(M_CUR_NORMAL);
1883     GrMouseSetCursorMode(M_CUR_RUBBER,xanchor,yanchor,GrColor);
1884     GrMouseSetCursorMode(M_CUR_LINE,xanchor,yanchor,GrColor);
1885     GrMouseSetCursorMode(M_CUR_BOX,dx1,dy1,dx2,dy2,GrColor);
1886
1887The anchor parameters for the rubberband and rubberline modes specify a
1888fixed screen location to which the other corner of the primitive is
1889bound. The dx1 through dy2 parameters define the offsets of the corners
1890of the dragged box from the hotpoint of the mouse cursor. The color
1891value passed is always XOR-ed to the screen, i.e. if an application
1892wants the rubberband to appear in a given color on a given background
1893then it has to pass the XOR of these two colors to GrMouseSetCursorMode.
1894
1895The GrMouseGetEvent function is used to obtain the next mouse or
1896keyboard event. It takes a flag with various bits encoding the type of
1897event needed. It returns the event in a GrMouseEvent structure. The
1898relevant declarations from grx20.h:
1899
1900     void GrMouseGetEvent(int flags,GrMouseEvent *event);
1901
1902     typedef struct _GR_mouseEvent {    /* mouse event buffer structure */
1903       int  flags;                       /* event type flags (see above) */
1904       int  x,y;                         /* mouse coordinates */
1905       int  buttons;                     /* mouse button state */
1906       int  key;                         /* key code from keyboard */
1907       int  kbstat;                      /* keybd status (ALT, CTRL, etc..) */
1908       long dtime;                       /* time since last event (msec) */
1909     } GrMouseEvent;
1910
1911The event structure has been extended with a keyboard status word (thus
1912a program can check for combinations like ALT-<left mousebutton press>)
1913and a time stamp which can be used to check for double clicks, etc...
1914The following macros have been defined in grx20.h to help in creating
1915the control flag for GrMouseGetEvent and decoding the various bits in
1916the event structure:
1917
1918     #define GR_M_MOTION         0x001       /* mouse event flag bits */
1919     #define GR_M_LEFT_DOWN      0x002
1920     #define GR_M_LEFT_UP        0x004
1921     #define GR_M_RIGHT_DOWN     0x008
1922     #define GR_M_RIGHT_UP       0x010
1923     #define GR_M_MIDDLE_DOWN    0x020
1924     #define GR_M_MIDDLE_UP      0x040
1925     #define GR_M_BUTTON_DOWN    (GR_M_LEFT_DOWN  | GR_M_MIDDLE_DOWN | \
1926                                  GR_M_RIGHT_DOWN | GR_M_P4_DOWN | GR_M_P5_DOWN)
1927     #define GR_M_BUTTON_UP      (GR_M_LEFT_UP    | GR_M_MIDDLE_UP   | \
1928                                  GR_M_RIGHT_UP   | GR_M_P4_UP  | GR_M_P5_UP)
1929     #define GR_M_BUTTON_CHANGE  (GR_M_BUTTON_UP  | GR_M_BUTTON_DOWN )
1930
1931     #define GR_M_LEFT           0x01        /* mouse button index bits */
1932     #define GR_M_RIGHT          0x02
1933     #define GR_M_MIDDLE         0x04
1934     #define GR_M_P4             0x08        /* wheel rolls up */
1935     #define GR_M_P5             0x10        /* wheel rolls down */
1936
1937     #define GR_M_KEYPRESS       0x080        /* other event flag bits */
1938     #define GR_M_POLL           0x100
1939     #define GR_M_NOPAINT        0x200
1940     #define GR_COMMAND          0x1000
1941     #define GR_M_EVENT          (GR_M_MOTION | GR_M_KEYPRESS | \
1942                                  GR_M_BUTTON_CHANGE | GR_COMMAND)
1943
1944GrMouseGetEvent will display the mouse cursor if it was previously
1945erased and the GR_M_NOPAINT bit is not set in the flag passed to it. In
1946this case it will also erase the cursor after an event has been
1947obtained.
1948
1949GrMouseGetEvent block until a event is produced, except if the
1950GR_M_POLL bit is set in the flag passed to it.
1951
1952Another version of GetEvent:
1953
1954     void GrMouseGetEventT(int flags,GrMouseEvent *event,long timout_msecs);
1955
1956can be istructed to wait timout_msec for the presence of an event. Note
1957that event->dtime is only valid if any event occured (event->flags !=
19580) otherwise it's set as -1. Additionally event timing is real world
1959time even in X11 && Linux.
1960
1961If there are one or more events waiting the function:
1962
1963     int  GrMousePendingEvent(void);
1964
1965returns non-zero value.
1966
1967The generation of mouse and keyboard events can be individually enabled
1968or disabled (by passing a non-zero or zero, respectively, value in the
1969corresponding enable_XX parameter) by calling:
1970
1971     void GrMouseEventEnable(int enable_kb,int enable_ms);
1972
1973Note that GrMouseInit set both by default. If you want to use
1974GrMouseGetEvent and GrKeyRead at the same time, a call to
1975GrMouseEventEnable( 0,1 ) is needed before input process.
1976
1977See the *test/mousetst.c* example.
1978
1979
1980File: grx249um.inf,  Node: Writing/reading PNM graphics files,  Next: Writing/reading PNG graphics files,  Prev: Mouse event handling,  Up: A User Manual For GRX2
1981
1982Writing/reading PNM graphics files
1983==================================
1984
1985GRX includes functions to load/save a context from/to a PNM file.
1986
1987PNM is a group of simple graphics formats from the NetPbm
1988(http://netpbm.sourceforge.net) distribution. NetPbm can convert
1989from/to PNM lots of graphics formats, and apply some transformations to
1990PNM files.  (Note. You don't need the NetPbm distribution to use this
1991functions).
1992
1993There are six PNM formats:
1994
1995       P1 text PBM (bitmap)
1996       P2 text PGM (gray scale)
1997       P3 text PPM (real color)
1998       P4 binary PBM (bitmap)
1999       P5 binary PGM (gray scale)
2000       P6 binary PPM (real color)
2001
2002GRX can handle the binary formats only (get the NetPbm distribution if
2003you need convert text to binary formats).
2004
2005To save a context in a PNM file you have three functions:
2006
2007     int GrSaveContextToPbm( GrContext *grc, char *pbmfn, char *docn );
2008     int GrSaveContextToPgm( GrContext *grc, char *pgmfn, char *docn );
2009     int GrSaveContextToPpm( GrContext *grc, char *ppmfn, char *docn );
2010
2011they work both in RGB and palette modes, grc must be a pointer to the
2012context to be saved, if it is NULL the current context is saved; p-mfn
2013is the file name to be created and docn is an optional text comment to
2014be written in the file, it can be NULL. Three functions return 0 on
2015succes and -1 on error.
2016
2017GrSaveContextToPbm dumps a context in a PBM file (bitmap). If the pixel
2018color isn't Black it asumes White.
2019
2020GrSaveContextToPgm dumps a context in a PGM file (gray scale). The
2021colors are quantized to gray scale using .299r + .587g + .114b.
2022
2023GrSaveContextToPpm dumps a context in a PPM file (real color).  To load
2024a PNM file in a context you must use:
2025
2026     int GrLoadContextFromPnm( GrContext *grc, char *pnmfn );
2027
2028it support reading PBM, PGM and PPM binary files. grc must be a pointer
2029to the context to be written, if it is NULL the current context is
2030used; p-mfn is the file name to be read. If context dimensions are
2031lesser than pnm dimensions, the function loads as much as it can. If
2032color mode is not in RGB mode, the routine allocates as much colors as
2033it can. The function returns 0 on succes and -1 on error.
2034
2035To query the file format, width and height of a PNM file you can use:
2036
2037     int GrQueryPnm( char *ppmfn, int *width, int *height, int *maxval );
2038
2039pnmfn is the name of pnm file; width returns the pnm width; height
2040returns the pnm height; maxval returns the max color component value.
2041The function returns 1 to 6 on success (the PNM format) or -1 on error.
2042
2043The two next functions:
2044
2045     int GrLoadContextFromPnmBuffer( GrContext *grc, const char *pnmbuf );
2046     int GrQueryPnmBuffer( const char *pnmbuf, int *width, int *height, int *maxval );
2047
2048work like GrLoadContextFromPnm and GrQueryPnmBuffer, but they get his
2049input from a buffer instead of a file. This way, pnm files can be
2050embeded in a program (using the bin2c program by example).
2051
2052
2053File: grx249um.inf,  Node: Writing/reading PNG graphics files,  Next: Writing/reading JPEG graphics files,  Prev: Writing/reading PNM graphics files,  Up: A User Manual For GRX2
2054
2055Writing/reading PNG graphics files
2056==================================
2057
2058GRX includes functions to load/save a context from/to a png file. But
2059note, for this purpose it needs the libpng
2060(http://www.libpng.org/pub/png/libpng.html) library, and to enable the
2061png support before make the GRX lib.
2062
2063Use next function to save a context in a PNG file:
2064
2065     int GrSaveContextToPng( GrContext *grc, char *pngfn );
2066
2067it works both in RGB and palette modes, grc must be a pointer to the
2068context to be saved, if it is NULL the current context is saved; pngfn
2069is the file name to be created.  The function returns 0 on succes and
2070-1 on error.
2071
2072To load a PNG file in a context you must use:
2073
2074     int GrLoadContextFromPng( GrContext *grc, char *pngfn, int use_alpha );
2075
2076grc must be a pointer to the context to be written, if it is NULL the
2077current context is used; pngfn is the file name to be read; set
2078use_alpha to 1 if you want to use the image alpha channel (if
2079available). If context dimensions are lesser than png dimensions, the
2080function loads as much as it can. If color mode is not in RGB mode, the
2081routine allocates as much colors as it can. The function returns 0 on
2082succes and -1 on error.
2083
2084To query the width and height of a PNG file you can use:
2085
2086     int GrQueryPng( char *pngfn, int *width, int *height );
2087
2088pngfn is the name of png file; width returns the png width; height
2089returns the png height.  The function returns 0 on success or -1 on
2090error.
2091
2092The function:
2093
2094     int GrPngSupport( void );
2095
2096returns 1 if there is png support in the library, 0 otherwise. If there
2097is not support for png, dummy functions are added to the library,
2098returning error (-1) ever.
2099
2100
2101File: grx249um.inf,  Node: Writing/reading JPEG graphics files,  Next: Miscellaneous functions,  Prev: Writing/reading PNG graphics files,  Up: A User Manual For GRX2
2102
2103Writing/reading PNG graphics files
2104==================================
2105
2106GRX includes functions to load/save a context from/to a jpeg file. But
2107note, for this purpose it needs the libjpeg (http://www.ijg.org)
2108library, and to enable the jpeg support before make the GRX lib.
2109
2110Use next function to save a context in a JPEG file:
2111
2112     int GrSaveContextToJpeg( GrContext *grc, char *jpegfn, int quality );
2113
2114it works both in RGB and palette modes, grc must be a pointer to the
2115context to be saved, if it is NULL the current context is saved; jpegfn
2116is the file name to be created; quality is a number between 1 and 100
2117to drive the compression quality, use higher values for better quality
2118(and bigger files), you can use 75 as a standard value, normally a
2119value between 50 and 95 is good.  The function returns 0 on succes and
2120-1 on error.
2121
2122This function saves a context in a grayscale JPEG file:
2123
2124     int GrSaveContextToGrayJpeg( GrContext *grc, char *jpegfn, int quality );
2125
2126parameters and return codes are like in GrSaveContextToJpeg.  The
2127colors are quantized to gray scale using .299r + .587g + .114b.
2128
2129To load a JPEG file in a context you must use:
2130
2131     int GrLoadContextFromJpeg( GrContext *grc, char *jpegfn, int scale );
2132
2133grc must be a pointer to the context to be written, if it is NULL the
2134current context is used; jpegfn is the file name to be read; set scale
2135to 1, 2, 4 or 8 to reduce the loaded image to 1/1, 1/2, 1/4 or 1/8. If
2136context dimensions are lesser than jpeg dimensions, the function loads
2137as much as it can. If color mode is not in RGB mode, the routine
2138allocates as much colors as it can. The function returns 0 on succes
2139and -1 on error.
2140
2141To query the width and height of a JPEG file you can use:
2142
2143     int GrQueryJpeg( char *jpegfn, int *width, int *height );
2144
2145jpegfn is the name of jpeg file; width returns the jpeg width; height
2146returns the jpeg height.  The function returns 0 on success or -1 on
2147error.
2148
2149The function:
2150
2151     int GrJpegSupport( void );
2152
2153returns 1 if there is jpeg support in the library, 0 otherwise. If
2154there is not support for jpeg, dummy functions are added to the
2155library, returning error (-1) ever.
2156
2157
2158File: grx249um.inf,  Node: Miscellaneous functions,  Next: BGI interface,  Prev: Writing/reading JPEG graphics files,  Up: A User Manual For GRX2
2159
2160Miscellaneous functions
2161=======================
2162
2163Here we will describe some miscellaneous functions.
2164
2165     unsigned GrGetLibraryVersion(void);
2166
2167GrGetLibraryVersion returns the GRX version API, like a hexadecimal
2168coded number. By example 0x0241 means 2.4.1 Because grx20.h defines the
2169GRX_VERSION_API macro, you can check if both, the library and the
2170include file, are in the same version using if(GrGetLibraryVersion() ==
2171GRX_VERSION_API )
2172
2173     unsigned GrGetLibrarySystem(void);
2174
2175This functions returns a unsigned integer identifing the system you are
2176working in. grx20.h defines some macros you can use:
2177
2178     /* these are the supported configurations: */
2179     #define GRX_VERSION_TCC_8086_DOS        1   /* also works with BCC */
2180     #define GRX_VERSION_GCC_386_DJGPP       2   /* DJGPP v2 */
2181     #define GRX_VERSION_GCC_386_LINUX       3   /* the real stuff */
2182     #define GRX_VERSION_GENERIC_X11         4   /* generic X11 version */
2183     #define GRX_VERSION_WATCOM_DOS4GW       5   /* GS - Watcom C++ 11.0 32 Bit
2184     #define GRX_VERSION_GCC_386_WIN32       7   /* WIN32 using Mingw32 */
2185     #define GRX_VERSION_MSC_386_WIN32       8   /* WIN32 using MS-VC */
2186     #define GRX_VERSION_GCC_386_CYG32       9   /* WIN32 using CYGWIN */
2187     #define GRX_VERSION_GCC_386_X11        10   /* X11 version */
2188     #define GRX_VERSION_GCC_X86_64_LINUX   11   /* console framebuffer 64 */
2189     #define GRX_VERSION_GCC_X86_64_X11     12   /* X11 version 64 */
2190
2191Note. On Linux, GrGetLibrarySystem returns GRX_VERSION_GCC_386_LINUX
2192even in the X11 version.
2193
2194     void GrSetWindowTitle(char *title);
2195GrSetWindowTitle sets the main window title in the X11 an Win32
2196versions. It doesn't do nothing in the DOS and Linux-SvgaLib versions.
2197
2198     void GrSleep(int msec);
2199This function stops the program execution for msec miliseconds.
2200
2201     long GrMsecTime( void );
2202This function gives the current time with millisecond resolution
2203
2204     void GrFlush( void );
2205This funnction flushes the graphics window. Not dummy because useful
2206only on X11 when switching between graphics and console windows open
2207simultaneously.
2208
2209      GrContext *GrCreateFrameContext(GrFrameMode md,int w,int h,
2210                 char far *memory[4],GrContext *where);
2211This function is like GrCreateContext, except that you can specify any
2212valid memory frame mode, not only the Screen associated frame mode. It
2213can be used for special purposes (see GrBitBlt1bpp for an example).
2214
2215      void GrBitBlt1bpp(GrContext *dst,int dx,int dy,GrContext *src,
2216           int x1,int y1,int x2,int y2,GrColor fg,GrColor bg);
2217This special function does a bitblt from a 1bpp context (a bitmap
2218really), using fg and bg like the color+opcode when bit=1 and bit=0
2219respectively. Here is an example:
2220
2221        pContext = GrCreateFrameContext(GR_frameRAM1, sizex, sizey, NULL, NULL);
2222        /* draw something (black and white) into the bitmap */
2223        GrSetContext(pContext);
2224        GrClearContext( GrBlack() );
2225        GrLine(0, 0, sizex-1, sizey-1, GrWhite());
2226        GrLine(0, sizey-1, sizex-1, 0, GrWhite());
2227
2228        /* Put the bitmap into the screen */
2229        GrSetContext(NULL);
2230        fcolor = GrAllocColor( 255,0,0 );
2231        bcolor = GrAllocColor( 0,0,255 );
2232        GrBitBlt1bpp(NULL,x,y,pContext,0,0,sizex-1,sizey-1,fcolor,bcolor);
2233
2234
2235File: grx249um.inf,  Node: BGI interface,  Next: Pascal interface,  Prev: Miscellaneous functions,  Up: A User Manual For GRX2
2236
2237BGI interface
2238=============
2239
2240From the 2.3.1 version, GRX includes the BCC2GRX library created by
2241Hartmut Schirmer. The BCC2GRX was created to allow users of GRX to
2242compile graphics programs written for Borland-C++ and Turbo-C graphics
2243interface. BCC2GRX is not a convenient platform to develop new BGI
2244programs. Of course you should use native GRX interface in such cases!
2245
2246Read the readme.bgi file for more info.
2247
2248
2249File: grx249um.inf,  Node: Pascal interface,  Next: References,  Prev: BGI interface,  Up: A User Manual For GRX2
2250
2251Pascal interface
2252================
2253
2254The Pascal (gpc) support is produced by two unit files *pascal/grx.pas*
2255and *pascal/bgi/graph.pas* which are the Pascal translations of the C
2256header files *include/grx20.h + include/grxkeys.h* and
2257*include/libbcc.h*.
2258
2259Compilation of the examples and installation of the header files is
2260allowed by setting INCLUDE_GPC_SUPPORT=y in makedef.grx.
2261
2262The unit files contain at the  beginning instructions to load the
2263required libraries (libgrx20..., depending on the system) and addon
2264libraries (e.g. libpng).  You can uncomment manually the addons you
2265want.  You can also use the configure script which does that
2266automatically, together with editing the makedefs.grx file.
2267
2268By default they are installed in a *units* directory below the
2269INSTALLDIR directory. But you can put them where you like.
2270
2271
2272File: grx249um.inf,  Node: References,  Prev: Pascal interface,  Up: A User Manual For GRX2
2273
2274References
2275==========
2276
2277Official GRX site              `http://grx.gnu.de'
2278GRX mailing list archive       `http://grx.gnu.de/archive/grx/en/'
2279MGRX site (fork from GRX)      `http://mgrx.fgrim.com'
2280NetPbm distribution            `http://netpbm.sourceforge.net'
2281PNG library                    `http://www.libpng.org/pub/png/libpng.html'
2282JPEG library                   `http://www.ijg.org'
2283TIFF library                   `http://www.remotesensing.org/libtiff/'
2284
2285
2286
2287Tag Table:
2288Node: Top198
2289Node: A User Manual For GRX21387
2290Node: Hello world2236
2291Node: Data types and function declarations4021
2292Node: Setting the graphics driver4755
2293Node: Setting video modes5866
2294Node: Graphics contexts10923
2295Node: Context use18111
2296Node: Color management19492
2297Node: Portable use of a few colors24538
2298Node: Graphics primitives26456
2299Node: Non-clipping graphics primitives35143
2300Node: Customized line drawing36646
2301Node: Pattern filled graphics primitives39000
2302Node: Patterned line drawing45938
2303Node: Image manipulation47507
2304Node: Text drawing50338
2305Node: Drawing in user coordinates64451
2306Node: Graphics cursors70791
2307Node: Keyboard input73353
2308Node: Mouse event handling75355
2309Node: Writing/reading PNM graphics files84879
2310Node: Writing/reading PNG graphics files87934
2311Node: Writing/reading JPEG graphics files89779
2312Node: Miscellaneous functions92098
2313Node: BGI interface95535
2314Node: Pascal interface96080
2315Node: References97023
2316
2317End Tag Table
2318