home *** CD-ROM | disk | FTP | other *** search
- /*
- Copyright 1990 by John Wiley & Sons, Inc.
- All Rights Reserved.
- */
- /****************************************/
- /* Focus Window Digitizer Program */
- /* written in Turbo C 2.0 */
- /* by */
- /* Craig A. Lindley */
- /* */
- /* Vers: 1.0 Last Update: 09/14/89 */
- /****************************************/
-
- /*
- This program is capable of the full utilization of the
- Video Digitizer hardware. It can cause the digitizer to
- digitize any portion of a video display. All aspects of
- a digitized image from acquisition to display
- are computed dynamically. The ImageReq structure is
- passed to the low level code to command the digitizer.
- */
-
- #include <stdio.h>
- #include <conio.h>
- #include <dos.h>
- #include <process.h>
- #include <graphics.h>
- #include <alloc.h>
- #include "misc.h"
- #include "pcx.h"
- #include "vga.h"
- #include "digitizer.h"
-
- /*
- The two defines offset the focus window so it
- is displayed in the center on the VGA screen.
- */
-
- #define ColCenterOffset 110
- #define RowCenterOffset 50
-
- /* Global Variables to this file */
-
- static struct ImageReq Req;
- static char huge *PictureData;
-
- /* display the digitized image */
- void DisplayPictData (char huge *PictData)
- {
- register unsigned Col, Row, Color;
- unsigned ColSpan, RowSpan;
- unsigned long PixelBufOffset;
-
- ColSpan = Req.LastPixel - Req.FirstPixel;
- RowSpan = Req.LastLine - Req.FirstLine;
- for (Col=0; Col < ColSpan; Col++)
- {
- PixelBufOffset = (long) RowSpan * Col;
- for (Row=0; Row < RowSpan; Row++)
- {
- Color = PictData[PixelBufOffset + Row];
- Color >>= 2;
- PutPixel256(Col+ColCenterOffset,
- Row+RowCenterOffset,Color);
- }
- }
- }
-
- /* main digitizer program */
-
- void main(void)
- {
- unsigned long RasterSize;
-
- InitGraphics(); /* initialize graphics subsystem */
-
- printf("Focus Window Test Program\n\n");
- printf("This program will continually digitize and display\n");
- printf("a small portion of the video field\n\n");
-
- /*
- Build a structure that defines what the digitizer should acquire. this
- will be passed to the digitizer by a call to InitializeDigitizer
- function
- */
-
- Req.ComputerType = PS220;
- Req.PrtBase = 0x3BC;
- Req.HMode = LowRes; /* 320x200 resolution mode */
- Req.VMode = NonInterlace;
- Req.NumberOfPasses = 1;
- Req.Flags = 0L;
- Req.FirstLine = 50; /* set up focus window */
- Req.FirstPixel = 110;
- Req.LastLine = 150;
- Req.LastPixel = 210;
-
- RasterSize = (Req.LastLine - Req.FirstLine) *
- (Req.LastPixel - Req.FirstPixel);
-
- /* allocate picture buffer and set it to zeros */
- printf("Allocating Image Buffer - RasterSize is %lu bytes\n\n",RasterSize);
-
- if ((PictureData = (char huge *) farcalloc(RasterSize,
- (unsigned long) sizeof(char))) == NULL)
- {
- printf("Digitize - Not enough memory\n");
- exit(ENoMemory);
- }
-
- printf("Hit any key to terminate program\n\n");
- printf("Acquiring Image . . .\n");
-
- Req.PictBuf = PictureData;
-
- InitializeDigitizer(&Req);
-
- delay(5000); /* allow messages to be read */
-
- Set256ColorMode(); /* 320x200 256 color VGA mode 13H */
-
- LoadGray16Palette(); /* load the gray scale palette */
-
- while (!kbhit()) /* acquire a picture continually */
- { /* until operator hits key */
- GetPicture();
- DisplayPictData(PictureData);
- }
- getch(); /* empty key buffer */
- restorecrtmode(); /* back to text mode */
- farfree((char far *)PictureData); /* give back the memory */
- closegraph(); /* close up shop */
- }
-