home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c013 / 34.ddi / CCVECTOR / INSIGHT.100 / MWSL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-26  |  7.4 KB  |  283 lines

  1. //▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  2. //▒                                                                         ▒
  3. //▒   CCVECTOR INSIGHT Ver 1.00                                             ▒
  4. //▒                                                                         ▒
  5. //▒   All rights reserved.  Copyright (c)  1992,1993                        ▒
  6. //▒                                                                         ▒
  7. //▒   Miniway Software Development Corp.                                    ▒
  8. //▒                                                                         ▒
  9. //▒   Beijing, P. R. China                                                  ▒
  10. //▒                                                                         ▒
  11. //▒   Phone: 255.6266, 257.1113-1108, 1308                                  ▒
  12. //▒                                                                         ▒
  13. //▒     Fax: 255.6266                                                       ▒
  14. //▒                                                                         ▒
  15. //▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  16. #include <graphics.h>
  17. #include <stdlib.h>
  18. #include <stdio.h>
  19. #include <conio.h>
  20. #include <io.h>
  21. #include <dos.h>
  22. #include <stdio.h>
  23. #include <time.h>
  24. #include <string.h>
  25.  
  26.  
  27. typedef struct DotFile { int  Index;
  28.                         char *FileName;
  29.                        };
  30.  
  31. struct DotFile DotFiles[]={   {0,  "CVFONT.001"},
  32.                   {1,  "CVFONT.002"},
  33.                   {2,  "CVFONT.003"},
  34.                   {3,  "CVFONT.004"},
  35.                   {12, "CVFONT.005"},
  36.                               {14, "CVFONT.006"},
  37.                   {7,  "CVFONT.007"},
  38.                   {4,  "CVFONT.008"},
  39.                   {11, "CVFONT.009"},
  40.                   {5,  "CVFONT.010"},
  41.                   {8,  "CVFONT.011"},
  42.                   {13, "CVFONT.012"},
  43.                   {6,  "CVFONT.013"},
  44.                               {29, "CVFONT.014"},
  45.                   {15, "CVFONT.015"},
  46.                   {16, "CVFONT.016"},
  47.                   {17, "CVFONT.017"},
  48.                   {18, "CVFONT.018"},
  49.                   {24, "CVFONT.019"},
  50.                   {25, "CVFONT.020"},
  51.                   {23, "CVFONT.021"},
  52.                   {21, "CVFONT.022"},
  53.                   {22, "CVFONT.023"},
  54.                   {27, "CVFONT.024"},
  55.                   {28, "CVFONT.025"},
  56.                   {26, "CVFONT.026"}
  57.               };
  58.  
  59.  
  60.  
  61. unsigned char * GetDOTS(unsigned int ccode,
  62.                              int FileIndex,
  63.                      int FHandle,
  64.                      int Width,
  65.                      int Height);
  66.  
  67.  
  68. /*▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒*/
  69. main(int args, char *argv[])
  70. {
  71. // display all fonts on screen */
  72.    int Height=95, Width=127, Handle; /*MAX is 368x368*/
  73.  
  74. // display each font on screen */
  75. // int Height=368, Width=368, Handle; /*MAX is 368x368*/
  76.  
  77. // display 4 font on screen */
  78. // int Height=239, Width=319, Handle; /*MAX is 368x368*/
  79.  
  80.  
  81.  
  82.  unsigned char BitValue[]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
  83.  unsigned int ccode=1601, code;
  84.  
  85.  int i,j,k,m,n,fnts_screen, retv;
  86.  int ii;
  87.  
  88.  unsigned char *buf;
  89.  unsigned int  *dos;
  90.  
  91.  unsigned int color_bk=7;
  92.  unsigned int color_fg=6;
  93.  unsigned int color_border=2;
  94.  unsigned int color_point=14;
  95.  
  96.  
  97.  
  98.    /* request auto detection */
  99.  int gdriver = DETECT, gmode, errorcode;
  100.  int Flag = 0 ;
  101.  
  102.  
  103.    /*** get hz's GB code ***/
  104.    if(args>1)
  105.      { i=atoi(argv[1]);
  106.        if(i>0 && i<=87)
  107.            ccode=i*100+1;
  108.        else
  109.        if(i>=1601 && i<=8794)
  110.          {
  111.            if((j=(i % 100))>=1 && j<=94) ccode=i;
  112.          }
  113.     }
  114.  
  115.    /* initialize graphics mode */
  116.    initgraph(&gdriver, &gmode, "");
  117.  
  118.    /* read result of initialization */
  119.    errorcode = graphresult();
  120.  
  121.    if(errorcode != grOk)  /* an graphics error occurred */
  122.      {
  123.        printf("Graphics error: %s\n", grapherrormsg(errorcode));
  124.        printf("Press any key to halt:");
  125.        getch();
  126.        exit(1);             /* return with error code */
  127.      }
  128.  
  129.   clearviewport();          /*** clear screen ***/
  130.  
  131.   color_bk=8;
  132.   color_fg=4;
  133.   color_border=9;
  134.   color_point=11;
  135.  
  136.  
  137.   while(1)
  138.   {
  139.     if((ccode % 100)>94) ccode=((ccode / 100)+1)*100+1;
  140.     if((ccode / 100)>87) ccode=1601;
  141.  
  142.     clearviewport();
  143.     setbkcolor(color_bk);
  144.     setcolor(color_border);
  145.  
  146.     rectangle(0,0,getmaxx(),getmaxy());
  147.  
  148.  
  149.     for(i=0, ii=-1; i<=26; i++)
  150.        {
  151.      if((Handle=open(DotFiles[i].FileName, 0))==-1) continue;
  152.  
  153.          ii++;
  154.  
  155.          buf=GetDOTS(ccode, DotFiles[i].Index, Handle,Width,Height);
  156.          close(Handle);
  157.  
  158.          if(buf == 0) continue;
  159.  
  160.          dos=(unsigned int *) (buf+16928/*0x3F48*/);
  161.  
  162.          /***
  163.               [buf] is a point of hz dots    buffer
  164.  
  165.               [dos] is a point of hz vectors buffer
  166.          ***/
  167.  
  168.          fnts_screen=(getmaxx()/Width)*(getmaxy()/Height);
  169.          setviewport( ( (ii%fnts_screen) % ((getmaxx())/Width ) )*Width        +1,
  170.                       ( (ii%fnts_screen) / ((getmaxy())/Height) )*Height       +1,
  171.                       ( (ii%fnts_screen) % ((getmaxx())/Width ) )*Width +Width ,
  172.                       ( (ii%fnts_screen) / ((getmaxy())/Height) )*Height+Height,
  173.                       1 );
  174.  
  175. /*********************** draw hz use its vectors ***************************/
  176. /****
  177.          setwritemode(COPY_PUT);
  178.          setfillstyle(SOLID_FILL, 7);
  179.          m=0;
  180.          while( (j=dos[m])>0 )
  181.               {
  182.                 m++;
  183.                 fillpoly(j, &dos[m]);
  184.                 m=m+j*2;
  185.               }
  186.          setwritemode(COPY_PUT);
  187.          getch();
  188. ****/
  189.  
  190.  
  191. /***************************** fill hz *************************************/
  192.          clearviewport();
  193.  
  194.      for(m=0; m<Width; m++)
  195.         for(n=0; n<Height; n++)
  196.            {
  197.            j=(m/8)*Height+n;
  198.           k=m % 8;
  199.          if(BitValue[k] & buf[j])
  200.            {
  201.              if( ( (n%2)&&(m%2) )  || ( !( n%2) && ! ( m % 2) ) )
  202.              putpixel(m,n,color_fg);
  203.              else
  204.              putpixel(m,n,color_fg);
  205.                    }
  206.            }
  207. //       getch();
  208.  
  209.  
  210. /****************************** draw outline *******************************/
  211.          clearviewport();
  212.       for(m=0; m<Width; m++)
  213.          for(n=0; n<Height; n++)
  214.             {
  215.           j=(m/8)*Height+n;
  216.           k=m % 8;
  217.  
  218.                   if( (BitValue[k] & buf[j]) && ( !Flag ) )
  219.             {
  220.               putpixel(m, n, color_fg); Flag = 1 ;
  221.             }
  222.           else
  223.           if( !(BitValue[k] & buf[j]) && ( Flag ) )
  224.             {
  225.               putpixel(m, n, color_fg); Flag = 0 ;
  226.             }
  227.  
  228.         }
  229.  
  230.      for(n=0; n<Height; n++)
  231.          for(m=0; m<Width; m++)
  232.             {
  233.               j=(m/8)*Height+n;
  234.               k=m % 8;
  235.  
  236.                   if( (BitValue[k] & buf[j]) && ( !Flag ) )
  237.             {
  238.                putpixel(m, n, color_fg); Flag = 1 ;
  239.             }
  240.                   else
  241.                   if( !(BitValue[k] & buf[j]) && ( Flag ) )
  242.             {
  243.               putpixel(m, n, color_fg); Flag = 0 ;
  244.             }
  245.             }
  246. //       getch();
  247.  
  248. /************************* display keypoints *******************************/
  249.  
  250.          m=0;
  251.          while( (j=dos[m])>0 )
  252.               {
  253.                 m++;
  254.                 while(j)
  255.                      {
  256.                        putpixel(dos[m], dos[m+1], color_point);
  257.                        m+=2;
  258.                        j--;
  259.                      }
  260.               }
  261. //       getch();
  262.  
  263.          setviewport( 0, 0, getmaxx(), getmaxy(), 0); /* CLIP=0:OFF */
  264.        }
  265.  
  266.    ccode++;
  267.  
  268.    if(kbhit())
  269.      {
  270.        if((i=getch())==0) i=getch()<<8;
  271.        if(i==27) break;
  272.      }
  273.  
  274.   }
  275.    getch();
  276.  
  277.    closegraph(); /* clean up */
  278.  
  279.    return 0;
  280. }
  281.  
  282.  
  283.