Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo Pascal - <b> getpic get graphics image pp 173</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 GETPIC                      Get Graphics Image                       pp 173

 Syntax:  GetPic (Buffer,X1,Y1,X2,Y2) ;

 Type:    N/A

 Form:    Extended Graphics Procedure

 Purpose: Copy rectangular screen area into buffer.

 Notes:   Requires {$I Graph.P} include file in the source file.
          The rectangular area defined by upper left coordinates X1,Y1
          and lower right coordinates X2,Y2 is copied from the screen to a
          user defined buffer.  Buffer type is any type.

          Buffer size required is mode dependent.
          Width = Abs(X1-X2) + 1  and  Height = Abs(1-Y2) + 1

          320x200: Bytes = ((Width+3) div 4) * Height * 2 + 6
          640x200: Bytes = ((Width+7) div 8) * Height + 6

          The first 6 bytes of the buffer constitue a three word header
          made up of three integers.  After the transfer, the first word
          contains the value '2' in 320x200 mode, or '1' in 640x200 mode.
          The second word contains the width of the image, and the third
          word contains the height.  The remaining bytes contina the data
          of the image.  Data is stored with the lefmost pixels in the most
          significant bits of each byte.  At the end of each row, the
          remaining bits ofthe last byte are skipped.


 ----------------------------------------------------------------------------


 Usage:
          {$I Graph.P}                     { Extended graphics support }
       CONST
          X1     : Integer = 0         ;   { Upper left screen corner }
          Y1     : Integer = 0         ;
          X2     : Integer = 319       ;   { Lower right screen corner }
          Y2     : Integer = 199       ;

       VAR
          Width  : Integer             ;   { Buffer width                   }
          Height : Integer             ;   { Buffer height                  }
          BfrCnt : Integer             ;   { Buffer size in bytes           }
          BfrPtr :^Integer             ;  { Define a pointer to heap buffer }

       BEGIN
          Width  := Abs(X1-X2) + 1     ;   { Calculate width                }
          Height := Abs(1-Y2) + 1      ;   { Calculate height               }
          BfrCnt := Width * Height     ;   { Calculate buffer size in bytes }
          GraphColorMode               ;   { Set 320x200 mode               }
          GetMem  (BfrPtr,BfrCnt)      ;   { Allocate HeapSpace buffer      }
          GetPic  (BfrPtr,X1,Y1,X2,Y2) ;   { Fill buffer with screen image  }
          PutPic  (BfrPtr,X1,Y2)       ;   { Lower left corner of screen    }
          FreeMem (BfrPtr,BfrCnt)      ;   { Release HeapSpace buffer       }
       END.

See Also: ColorTable FreeMem GetMem Pointer PutPic

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