home *** CD-ROM | disk | FTP | other *** search
- //SAMPLE.C
-
- //---------------------------Include & Define (start)------------------------
- #include <conio.h>
- #include <dos.h>
- #include "video.h"
-
- #define VIDEO 0x10
- #define TRUE 1
- #define FALSE 0
- #define ESC 27
-
-
- //-------------------------Local Function Declaration------------------------
- void _TestScale(void);
- void _Wait(int);
- void _CheckKB(void);
-
- // Memory buffer for storing video image data
- BYTE gbImageBuffer[60000];
-
- //-------------------------------Main program (start)------------------------
- main()
- {
- unsigned int i;
-
- VIDEO_SwitchMode(VIDEO_MODE_640x480x16);
- VIDEO_Initialize();
- VIDEO_SetVideoPos(0, 0, 640, 480);
- VIDEO_SetVideoSource(1);
- VIDEO_SetInputFormat(VIDEO_NTSC);
- VIDEO_SetHorizontalAlignment(102);
- VIDEO_SetVerticalAlignment(15);
- VIDEO_EnableVideo();
- VIDEO_UnfreezeVideo();
- getch();
-
- // for demostrating "Scale" function
- _TestScale();
-
- VIDEO_SetVideoPos(0, 0, 640, 480);
-
- getch();
-
- // for demostrating "Freeze" function
- VIDEO_FreezeVideo();
- // for demostrating "Capture video data" function
- VIDEO_LoadImageRect((BYTE _huge *)gbImageBuffer,
- 10, 10, 160,120,
- VIDEO_BMP_8_GRAY, 0);
- getch();
-
- // for demostrating "Restore video data" function
- VIDEO_RestoreImageRect((BYTE _huge *)gbImageBuffer,
- 320, 210, 160, 120,
- VIDEO_BMP_8_GRAY, 0);
- getch();
-
- VIDEO_End();
-
- VIDEO_SwitchMode(VIDEO_MODE_NORMAL);
- }
-
-
- //-------------------------Local Function (Start)----------------------------
- /*---------------------------------------------------------------------------
- | |
- | Function: _TestScale(void) |
- | |
- | Purpose: Test window scaling. |
- | |
- ---------------------------------------------------------------------------*/
- void _TestScale()
- {
- WORD lwWidth, lwHeight;
-
- for(lwWidth=75, lwHeight=55; lwHeight<=300; lwWidth+=20, lwHeight+=15) {
- VIDEO_SetVideoPos(320-lwWidth/2, 240-lwHeight/2, lwWidth, lwHeight);
- _Wait(50);
- _CheckKB();
- }
- }
-
- /*---------------------------------------------------------------------------
- | |
- | Function: _Wait(int) |
- | |
- | Purpose: Delay a little time. |
- | |
- ---------------------------------------------------------------------------*/
- void _Wait(int iDelay) //delay is in 1/10 seconds
- {
- register int i, k;
-
- k = iDelay;
- if(iDelay > 0) {
- for(i=0; i<k; i++) {
- while(!(inp(0x3da) & 0x08));
- while((inp(0x3da) & 0x08));
- }
- }
- }
-
-
- /*---------------------------------------------------------------------------
- | |
- | Function: void _CheckKB(void) |
- | |
- | Purpose: Check keyboard: |
- | 1. Press ESC key to exit any time. |
- | 2. First times, key is pressed to pause. |
- | 3. Second times, key is pressed to continue. |
- | |
- ---------------------------------------------------------------------------*/
- void _CheckKB()
- {
- if(!kbhit()) return;
- while(kbhit()) if(getch()==ESC) {
- VIDEO_SwitchMode(VIDEO_MODE_NORMAL);
- exit(0);
- }
- while(!kbhit());
- while(kbhit()) if(getch()==ESC) {
- VIDEO_SwitchMode(VIDEO_MODE_NORMAL);
- exit(0);
- }
- }
-
-
- //----------------------------------(End)----------------------------------
-