home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c005 / 5.ddi / C / WNGETIMG.C < prev    next >
Encoding:
C/C++ Source or Header  |  1986-08-05  |  2.3 KB  |  81 lines

  1. /**
  2. *
  3. * Name        wngetimg -- Read rectangular portion of screen image.
  4. *
  5. * Synopsis    presult = wngetimg(pimage,pwhere);
  6. *
  7. *        IMAGE *presult      Pointer to IMAGE structure read,
  8. *                  or NIL if failure.
  9. *        IMAGE *pimage      Pointer to IMAGE structure to fill
  10. *                  with data read from screen.
  11. *        WHERE *pwhere      Pointer to WHERE structure indicating
  12. *                  video device, display page, and
  13. *                  location on screen.
  14. *
  15. * Description    This function reads the contents a rectangular region of
  16. *        a display screen into a buffer specified by an IMAGE
  17. *        structure.
  18. *
  19. *        This function also selects the designated device and
  20. *        display page.
  21. *
  22. *        An error occurs if (1) the IMAGE structure pointed to by
  23. *        pimage does not contain a valid pointer to a data
  24. *        buffer, or if (2) the device or page designated by
  25. *        pwhere are invalid, or if (3) the dimensions specified
  26. *        by pimage->dim and the location specified by
  27. *        pwhere->corner are inappropriate for the display device.
  28. *
  29. * Returns    presult       Pointer to IMAGE structure read,
  30. *                  or NIL if failure.
  31. *        b_device      Video device.
  32. *        b_curpage      Current display page.
  33. *        b_wnerr       Possible values:
  34. *                  (No change)       Success.
  35. *                  WN_NULL_PTR       pimage->pdata is
  36. *                           invalid.
  37. *                  WN_BAD_DEV       Invalid device, page,
  38. *                           or dimensions.
  39. *                  WN_ILL_DIM       Internal error.
  40. *
  41. * Version    3.0  (C)Copyright Blaise Computing Inc. 1986
  42. *
  43. **/
  44.  
  45. #include <bgenvid.h>              /* This routine doesn't care    */
  46.                       /* whether direct or BIOS       */
  47.                       /* version of BGENVID.H is used.*/
  48. #include <bwindow.h>
  49.  
  50. IMAGE *wngetimg(pimage,pwhere)
  51. IMAGE *pimage;
  52. WHERE *pwhere;
  53. {
  54.     int old_npage;
  55.  
  56.     if (pimage->pdata == NIL)
  57.     {
  58.     wnerror(WN_NULL_PTR);
  59.     return NIL;
  60.     }
  61.  
  62.     if (wnseldev(pwhere,&pimage->dim,&old_npage))
  63.     {                      /* Validate and select device   */
  64.     wnerror(WN_BAD_DEV);          /* and page (also validate      */
  65.     return NIL;              /* dimensions).              */
  66.     }
  67.  
  68.     if (gvrdrect(pwhere->corner.row,
  69.          pwhere->corner.col,
  70.          pwhere->corner.row + pimage->dim.h - 1,
  71.          pwhere->corner.col + pimage->dim.w - 1,
  72.          (char *) pimage->pdata,CHAR_ATTR)
  73.         != pimage->dim.h * pimage->dim.w)
  74.     {
  75.     wnerror(WN_ILL_DIM);
  76.     return NIL;
  77.     }
  78.  
  79.     return pimage;              /* Success.              */
  80. }
  81.