⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 370-375.html

📁 The primary purpose of this book is to explain various data-compression techniques using the C progr
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "html.dtd"><HTML><HEAD><TITLE>The Data Compression Book-:Lossy Graphics Compression</TITLE><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"><SCRIPT><!--function displayWindow(url, width, height) {        var Win = window.open(url,"displayWindow",'width=' + width +',height=' + height + ',resizable=1,scrollbars=yes');}//--></SCRIPT></HEAD><BODY  BGCOLOR="#FFFFFF" VLINK="#DD0000" TEXT="#000000" LINK="#DD0000" ALINK="#FF0000"><TD WIDTH="540" VALIGN="TOP"><!--  <CENTER><TABLE><TR><TD><FORM METHOD="GET" ACTION="http://search.itknowledge.com/excite/cgi-bin/AT-foldocsearch.cgi"><INPUT NAME="search" SIZE="20" VALUE=""><BR><CENTER><INPUT NAME="searchButton" TYPE="submit" VALUE="Glossary Search"></CENTER><INPUT NAME="source" TYPE="hidden" VALUE="local" CHECKED> <INPUT NAME="bltext" TYPE="hidden" VALUE="Back to Search"><INPUT NAME="sp" TYPE="hidden" VALUE="sp"></FORM></TD><TD><IMG SRC="http://www.itknowledge.com/images/dotclear.gif" WIDTH="15"   HEIGHT="1"></TD><TD><FORM METHOD="POST" ACTION="http://search.itknowledge.com/excite/cgi-bin/AT-subscriptionsearch.cgi"><INPUT NAME="search" SIZE="20" VALUE=""><BR><CENTER><INPUT NAME="searchButton" TYPE="submit" VALUE="  Book Search  "></CENTER><INPUT NAME="source" TYPE="hidden" VALUE="local" CHECKED> <INPUT NAME="backlink" TYPE="hidden" VALUE="http://search.itknowledge.com:80/excite/AT-subscriptionquery.html"><INPUT NAME="bltext" TYPE="hidden" VALUE="Back to Search"><INPUT NAME="sp" TYPE="hidden" VALUE="sp"></FORM></TD></TR></TABLE></CENTER> --><!-- ISBN=1558514341//--><!-- TITLE=The Data Compression Book-//--><!-- AUTHOR=Mark Nelson//--><!-- PUBLISHER=IDG Books Worldwide, Inc.//--><!-- IMPRINT=M & T Books//--><!-- CHAPTER=11//--><!-- PAGES=370-375//--><!-- UNASSIGNED1//--><!-- UNASSIGNED2//--><CENTER><TABLE BORDER><TR><TD><A HREF="355-370.html">Previous</A></TD><TD><A HREF="../ewtoc.html">Table of Contents</A></TD><TD><A HREF="753-380.html">Next</A></TD></TR></TABLE></CENTER><P><BR></P><H3><A NAME="Heading34"></A><FONT COLOR="#000077">Support Programs</FONT></H3><P>The two support programs used in this chapter are GS.C, used to display &#147;non-format&#148; grey-scale files, and GSDIFF.C, used to display the differences between two files and to print the rms value of the error. They follow.</P><!--  CODE //--><PRE>/*************************** Start of GS.C *****************************/** This is the GS program, which displays grey-scale files on the* IBM VGA adaptor. It assumes that the grey-scale values run from* zero to 255, and scales them down to a range of zero to sixty-three,* so they will be displayed properly on the VGA.** This program can be called with a list of files, and will display them* in consecutive order, which is useful for trying to measure visual* differences in compressed files.** This program writes directly to video memory, which should work* properly on most VGA adaptors. In the event that it doesn't, the* constant USE_BIOS can be turned on, and the code will use BIOS calls* to write pixels instead. This will be somewhat slower, but should work* on every VGA adaptor.** Note that the use of far pointers means this program should probably* be compiled without using the strict ANSI option of your compiler.*/#include &lt;stdio.h&gt;#include &lt;stdlib.h&gt;#include &lt;dos.h&gt;#include &lt;conio.h&gt;main( int argc, char *argv[] ){ union REGS rin; union REGS rout; int i; FILE *file; char far *video; if ( argc &lt; 2 ) {  printf( "Usage: gs file\n\n" );  exit( 1 ); } rin.h.ah = 0; rin.h.al = 0x13; int86( 0x10, &amp;rin, &amp;rout ); rin.h.ah = 0x10; rin.h.al = 0x10;  for ( i = 0 ; i &lt; 64 ; i++ ) {   rin.h.dh = (unsigned char) i;   rin.h.ch = (unsigned char) i;   rin.h.cl = (unsigned char) i;   rin.x.bx = i;   int86( 0x10, &amp;rin, &amp;rout );  }  rin.h.ah = 0x10;  rin.h.al = 0x1b;  rin.x.cx = 256;  rin.x.bx = 0;  int86( 0x10. &amp;rin, &amp;rout );  argv++;  while ( &#151;argc &gt; 0 ) {   file = fopen( *argv++, "rb" );   if ( file == NULL ) {     putc( 7, stdout );     break;   }   video = (char far *) 0xA0000000L;   rin.h.ah = 0x0c;   rin.h.bh = 0;   for ( rin.x.dx = 0 ; rin.x.dx &lt; 200 ; rin.x.dx++ ) {     for ( rin.x.cx = 0 ; rin.x.cx &lt; 320 ; rin.x.cx++ ) {#ifdef USE_BIOS        rin.h.al = (unsigned char) ( getc( file ) &gt;&gt; 2);        int86( 0x10, &amp;rin, &amp;rout );#else        *video++ = (char) ( getc( file ) &gt;&gt; 2);#endif    }   }   fclose( file );   getch();  }  rin.h.ah = 0; rin.h.al = 3; int86( 0x10. &amp;rin, &amp;rout ); return 0;}/***************************** End of GS.C *****************************//***************************** Start of GSDIFF.C ************************* This is the GSDIFF program, which displays the differences between* two grey-scale files on the IBM VGA adaptor. It assumes that the* grey-scale values run from zero to 255, and scales them down to a* range of zero to sixty-three, so they will be displayed properly on* the VGA.** This program writes directly to video memory, which should work* properly on most VGA adaptors. In the event that it doesn't, the* constant USE_BIOS can be turned on, and the code will use BIOS calls* to write pixels instead. This will be somewhat slower, but should work* on every VGA adaptor.** While this program is writing out to the display, it is also keeping a* running total of the error differences. When the program is* complete, it prints out the RMS error. If the -B switch is turned* on, the program operates in batch mode, and doesn't display the* differences. It just computes and prints the rms error value.** Note that the use of far pointers means this program should probably* be compiled without using the strict ANSI option of your compiler.*/#include &lt;stdio.h&gt;#include &lt;stdlib.h&gt;#include &lt;string&gt;#include &lt;dos.h&gt;#include &lt;conio.h&gt;#include &lt;math.h&gt;main( int argc, char *argv[] ){ union REGS rin; union REGS rout; int i; FILE *file1; FILE *file2; int diff; int c1; int c2; char far *video; double error; int batch; if ( argc &lt; 3 ) {  printf( "Usage: gsdiff file1 file2 [-B]\n\n" );  exit( 1 ); } file1 = fopen( argv[ 1 ], "rb" ); file2 = fopen( argv[ 2 ], "rb" ); if ( file1 == NULL || file2 == NULL ) {  printf( "Could not open file!\n" );  exit( 1 ); } batch = 0; if ( argc &gt; 3 )  if ( strcmp( argv[ 3 ], "-b" ) == 0 ||   strcmp( argv [ 3 ], "-B" ) == 0 )   batch = 1; if ( !batch ) {  rin.h.ah = 0;  rin.h.al = 0x13;  int86( 0x10, &amp;rin, &amp;rout );  rin.h.ah = 0x10;  rin.h.al = 0x10;  for ( i = 0 ; i &lt; 64 ; i++ ) {    rin.h.dh = (unsigned char) i;    rin.h.ch = (unsigned char) i;    rin.h.cl = (unsigned char) i;    rin.x.bx = i;    int86( 0x10, &amp;rin, &amp;rout );  }  rin.h.ah = 0x10;  rin.h.al = 0x1b;  rin.x.cx = 256;  rin.x.bx = 0;  int86( 0x10, &amp;rin, &amp;rout ); } error = 0.0; video = (char far *) 0xA0000000L; rin.h.ah = 0x0c; rin.h.bh = 0; for ( rin.x.dx = 0 ; rin.x.dx &lt; 200 ; rin.x.dx++ ) {   for ( rin.x.cx = 0 ; rin.x.cx &lt; 320 ; rin.x.cx++ ) {    c1 = getc( file1 );    c2 = getc( file2 );    diff = c1 - c2;    error += diff*diff;    if ( diff &lt; 0 )     diff *= -1;    if ( diff &gt; 63 )     diff = 63;    if ( !batch ) {#ifdef USE_BIOS     rin.h.al = diff;     int86( 0x10, &amp;rin, &amp;rout );#else     *video++ = diff;#endif    }   } } fclose( file1 ); fclose( file2 ); if ( !batch ) {  getch();  rin.h.ah = 0;  rin.h.al = 3;  int86( 0x10, &amp;rin, &amp;rout ); } error /= 320.0 * 200.0; printf( "RMS error between %s and %s is %lf\n",  argv[ 1 ], argv[ 2 ], sqrt( error ) );  return 0; }/*************************** End of GSDIFF.C ***************************/</PRE><!--  END CODE //--><P><BR></P><CENTER><TABLE BORDER><TR><TD><A HREF="355-370.html">Previous</A></TD><TD><A HREF="../ewtoc.html">Table of Contents</A></TD><TD><A HREF="753-380.html">Next</A></TD></TR></TABLE></CENTER></TD></TR></TABLE></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -