home *** CD-ROM | disk | FTP | other *** search
/ Computer Tool Software / soft.iso / Multimed / WINFAST / WFST230 / DOS / EXAMPLE / SAMPLE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-19  |  4.4 KB  |  131 lines

  1. //SAMPLE.C
  2.  
  3. //---------------------------Include & Define (start)------------------------
  4. #include <conio.h>
  5. #include <dos.h>
  6. #include "video.h"
  7.  
  8. #define     VIDEO                   0x10
  9. #define     TRUE                    1                                      
  10. #define     FALSE                   0
  11. #define     ESC                     27                      
  12.  
  13.  
  14. //-------------------------Local Function Declaration------------------------
  15. void              _TestScale(void);
  16. void              _Wait(int);
  17. void              _CheckKB(void);
  18.  
  19. // Memory buffer for storing video image data
  20. BYTE gbImageBuffer[60000];
  21.  
  22. //-------------------------------Main program (start)------------------------
  23. main()
  24. {
  25.     unsigned int i;
  26.  
  27.     VIDEO_SwitchMode(VIDEO_MODE_640x480x16);
  28.     VIDEO_Initialize();
  29.     VIDEO_SetVideoPos(0, 0, 640, 480);
  30.     VIDEO_SetVideoSource(1);
  31.     VIDEO_SetInputFormat(VIDEO_NTSC);
  32.     VIDEO_SetHorizontalAlignment(102);
  33.     VIDEO_SetVerticalAlignment(15);        
  34.     VIDEO_EnableVideo();
  35.     VIDEO_UnfreezeVideo();
  36.     getch();
  37.  
  38.     // for demostrating "Scale" function
  39.     _TestScale();
  40.  
  41.     VIDEO_SetVideoPos(0, 0, 640, 480);
  42.  
  43.     getch();
  44.  
  45.     // for demostrating "Freeze" function
  46.     VIDEO_FreezeVideo();
  47.     // for demostrating "Capture video data" function
  48.     VIDEO_LoadImageRect((BYTE _huge *)gbImageBuffer,
  49.                         10, 10, 160,120,
  50.                         VIDEO_BMP_8_GRAY, 0);
  51.     getch();                                          
  52.  
  53.     // for demostrating "Restore video data" function
  54.     VIDEO_RestoreImageRect((BYTE _huge *)gbImageBuffer,
  55.                         320, 210, 160, 120,
  56.                         VIDEO_BMP_8_GRAY, 0);
  57.     getch();
  58.  
  59.     VIDEO_End();     
  60.  
  61.     VIDEO_SwitchMode(VIDEO_MODE_NORMAL);
  62. }
  63.  
  64.  
  65. //-------------------------Local Function (Start)----------------------------
  66. /*---------------------------------------------------------------------------
  67. |                                                                           |
  68. |  Function: _TestScale(void)                                               |
  69. |                                                                           |
  70. |  Purpose: Test window scaling.                                            |
  71. |                                                                           |
  72. ---------------------------------------------------------------------------*/
  73. void _TestScale()
  74. {
  75.     WORD        lwWidth, lwHeight;
  76.  
  77.     for(lwWidth=75, lwHeight=55; lwHeight<=300; lwWidth+=20, lwHeight+=15) {
  78.         VIDEO_SetVideoPos(320-lwWidth/2, 240-lwHeight/2, lwWidth, lwHeight);
  79.         _Wait(50);
  80.         _CheckKB();
  81.     }
  82. }
  83.  
  84. /*---------------------------------------------------------------------------
  85. |                                                                           |
  86. |  Function: _Wait(int)                                                     |
  87. |                                                                           |
  88. |  Purpose: Delay a little time.                                            |
  89. |                                                                           |
  90. ---------------------------------------------------------------------------*/
  91. void _Wait(int iDelay)     //delay is in 1/10 seconds
  92. {
  93.     register int i, k;
  94.  
  95.     k = iDelay;
  96.     if(iDelay > 0) {
  97.         for(i=0; i<k; i++) {
  98.             while(!(inp(0x3da) & 0x08));
  99.             while((inp(0x3da)  & 0x08));
  100.         }
  101.     }
  102. }
  103.  
  104.  
  105. /*---------------------------------------------------------------------------
  106. |                                                                           |
  107. |  Function: void _CheckKB(void)                                            |
  108. |                                                                           |
  109. |  Purpose: Check keyboard:                                                 |
  110. |           1. Press ESC key to exit any time.                              |
  111. |           2. First times,  key is pressed to pause.                       |
  112. |           3. Second times, key is pressed to continue.                    |
  113. |                                                                           |
  114. ---------------------------------------------------------------------------*/
  115. void _CheckKB()
  116. {
  117.     if(!kbhit()) return;
  118.     while(kbhit()) if(getch()==ESC) { 
  119.         VIDEO_SwitchMode(VIDEO_MODE_NORMAL);     
  120.         exit(0); 
  121.     }
  122.     while(!kbhit());
  123.     while(kbhit()) if(getch()==ESC) { 
  124.         VIDEO_SwitchMode(VIDEO_MODE_NORMAL);     
  125.         exit(0); 
  126.     }
  127. }
  128.         
  129.         
  130. //----------------------------------(End)----------------------------------
  131.