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>_imagesize() return an image size (in bytes)</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 _imagesize()            Return an image size (in bytes)

 #include   <graph.h>

 long far _imagesize(x1, y1, x2, y2);
  short x1, y1;     Upper-left corner of bounding rectangle
  short x2, y2;     Lower-right corner of bounding rectangle

    _imagesize() returns the number of bytes needed to store the image
    defined by the bounding rectangle having coordinates (x1, y1) as the
    upper-left corner and (x2, y2) as the lower-right corner.

    The image size is determined by the following formula:

    xwid = abs(x1-x2) + 1;
    ywid = abs(y1-y2) + 1;
    size = 4 + ((long) ((xwid*bits-per-pixel + 7) / 8) * (long)ywid);

    The bits-per-pixel value is returned by _getvideoconfig() as the
    bitsperpixel member of struct videoconfig.

       Returns:     _imagesize() returns the image's storage size in
                    bytes.

         Notes:     The buffer that image points to must be large enough
                    to hold the image. The image size can be determined
                    at run time by calling _imagesize(), or by using the
                    following formula:

                    xwid = abs(x1-x2) + 1;
                    ywid = abs(y1-y2) + 1;
                    size = 4 + ((long) ((xwid*bits-per-pixel + 7) / 8) *
                    (long)ywid);

                    The bits-per-pixel value is returned by
                    _getvideoconfig() as the bitsperpixel member of
                    struct videoconfig.

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

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

    This program draws a pie-shape, stores it in memory, retrieves it,
    and displays it in a second location.

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

           char far *image;

           main()
           {
              int xvar, yvar;

              _setvideomode( _MRES4COLOR );
              _pie( _GFILLINTERIOR, 90, 60, 250, 160, 250, 22, 10, 160 );

              image = (char far *) malloc( (unsigned int)
                                        _imagesize( 90, 60, 250, 160 ) );
              if ( image == (char far *) NULL )
                 exit(-1);
              _getimage( 90, 60, 250, 160, image );
              _putimage( 0, 0, image, _GOR );

              free((char *) image);

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


See Also: _putimage() _getimage() _getvideoconfig()

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