Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>_getpixel() get a pixel value</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 _getpixel()             Get a pixel value

 #include   <graph.h>

 short far _getpixel( x, y );
  short x;     x coordinate (horizontal)
  short y;     y coordinate (vertical)

    _getpixel() gets the current color value of the pixel at logical
    point (x,y).  The translation of this color value is determined by
    the current palette.

       Returns:     _getpixel() returns the color value of the pixel
                    (x,y). If it fails (for example, if the point lies
                    outside of the clipping region), it will return a -1.

   Portability:     MS-DOS only, true MDPA, CGA, EGA, MCGA, or VGA video
                    compatibles

 -------------------------------- Example ---------------------------------

    This program draws a dotted line through a pie-shape, reversing the
    line where it intersects the pie.

           #include <conio.h>
           #include <graph.h>

           main()
           {
              struct xycoord xy;
              short color;
              int i;

              _setvideomode( _MRES4COLOR );
              color = _getcolor();
              _pie( _GFILLINTERIOR, 90, 60, 250, 160, 250, 22, 10, 160 );
              xy = _getviewcoord( 0, 0 );
              _moveto ( xy.xcoord, xy.ycoord );

              for ( i = 0; i < 72; i++ )
                 {
                 xy = _getcurrentposition( );
                 _moveto( xy.xcoord + 4, xy.ycoord + 2 );

                 /* test and reverse foreground and background colors */
                 if( _getpixel( xy.xcoord,  xy.ycoord) ==
                     (short) _getbkcolor() )
                    _setcolor( color );
                 else
                    _setcolor( (short) _getbkcolor() );
                 _setpixel( xy.xcoord,  xy.ycoord);
                 }

              while ( !kbhit() );
              _setvideomode( _DEFAULTMODE );
           }


See Also: _setpixel()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson