home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name wngetimg -- Read rectangular portion of screen image.
- *
- * Synopsis presult = wngetimg(pimage,pwhere);
- *
- * IMAGE *presult Pointer to IMAGE structure read,
- * or NIL if failure.
- * IMAGE *pimage Pointer to IMAGE structure to fill
- * with data read from screen.
- * WHERE *pwhere Pointer to WHERE structure indicating
- * video device, display page, and
- * location on screen.
- *
- * Description This function reads the contents a rectangular region of
- * a display screen into a buffer specified by an IMAGE
- * structure.
- *
- * This function also selects the designated device and
- * display page.
- *
- * An error occurs if (1) the IMAGE structure pointed to by
- * pimage does not contain a valid pointer to a data
- * buffer, or if (2) the device or page designated by
- * pwhere are invalid, or if (3) the dimensions specified
- * by pimage->dim and the location specified by
- * pwhere->corner are inappropriate for the display device.
- *
- * Returns presult Pointer to IMAGE structure read,
- * or NIL if failure.
- * b_device Video device.
- * b_curpage Current display page.
- * b_wnerr Possible values:
- * (No change) Success.
- * WN_NULL_PTR pimage->pdata is
- * invalid.
- * WN_BAD_DEV Invalid device, page,
- * or dimensions.
- * WN_ILL_DIM Internal error.
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1986
- *
- **/
-
- #include <bgenvid.h> /* This routine doesn't care */
- /* whether direct or BIOS */
- /* version of BGENVID.H is used.*/
- #include <bwindow.h>
-
- IMAGE *wngetimg(pimage,pwhere)
- IMAGE *pimage;
- WHERE *pwhere;
- {
- int old_npage;
-
- if (pimage->pdata == NIL)
- {
- wnerror(WN_NULL_PTR);
- return NIL;
- }
-
- if (wnseldev(pwhere,&pimage->dim,&old_npage))
- { /* Validate and select device */
- wnerror(WN_BAD_DEV); /* and page (also validate */
- return NIL; /* dimensions). */
- }
-
- if (gvrdrect(pwhere->corner.row,
- pwhere->corner.col,
- pwhere->corner.row + pimage->dim.h - 1,
- pwhere->corner.col + pimage->dim.w - 1,
- (char *) pimage->pdata,CHAR_ATTR)
- != pimage->dim.h * pimage->dim.w)
- {
- wnerror(WN_ILL_DIM);
- return NIL;
- }
-
- return pimage; /* Success. */
- }