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

📄 the tiff image file format.htm

📁 Tiff Image File format(英文版)
💻 HTM
📖 第 1 页 / 共 3 页
字号:
<P align=justify>&nbsp;</P><B>
<P align=justify>DIR.C</B> This file contains the code that parses the TIFF 
directory structure (the IFH, the IFDs, and the DEs) on reading a TIFF file and 
builds the directory structure when writing TIFF files. This is where the 
majority of the difficult code resides.</P>
<P align=justify>&nbsp;</P><B>
<P align=justify>ERROR.C</B> This file contains the functions that produce the 
warning and error messages that are output when improperly formatted TIFF files 
are read or written.</P>
<P align=justify>&nbsp;</P><B>
<P>SWAB.C</B> This file contains the code that performs all byte reordering 
operations.</P>
<P>&nbsp;</P><B>
<P align=justify>PRINT.C</B> This file contains a utility program which is used 
to dump all tag information from a TIFF file for user inspection. This code is 
utilized by the "view.exe" example program described shortly.</P>
<P align=justify>&nbsp;</P><B>
<P align=justify>COMPRESS.C</B> This short file contains a function that selects 
the compression algorithm to be used when reading and/or writing TIFF files.</P>
<P align=justify>&nbsp;</P><B>
<P align=justify>DUMPMODE.C</B> This file has the code that handles files that 
do not utilize data compression of the raster data. In other words, these 
functions read and write noncompressed TIFF files.</P></DIR>
<DIR><B>
<P align=justify>CCITT.C</B> This file contains the stubs where the CCITT 
compression algorithms would be added to the function library. Currently, these 
stubs produce an error message, indicating that the TIFF function library does 
not support these compression methods.</P>
<P align=justify>&nbsp;</P><B>
<P align=justify>PACKBITS.C</B> This file contains the code to read and write 
TIFF files that utilize compression method 32773. This method is referred to as 
the "Macintosh PackBits" method.</P>
<P align=justify>&nbsp;</P><B>
<P align=justify>LZW.C</B> This file contains the code to read and write image 
raster data compressed using the Lempel-Ziv &amp; Welch method.</P>
<P align=justify>&nbsp;</P></DIR></FONT>
<P align=center>
<CENTER>
<TABLE borderColor=#000000 cellSpacing=2 cellPadding=11 width=624 border=1>
  <TBODY>
  <TR>
    <TD vAlign=top><FONT face="Times New Roman">
      <P>Unfortunately, the files that comprise the TIFF function library just 
      listed are too long to list here.</FONT></P></TD></TR></TBODY></TABLE></CENTER>
<P></P><B><FONT face="Times New Roman">
<P align=justify>&nbsp;</P>
<DIR>
<P align=justify>TIFFINTF.H</B></B> This file is an interface file to be used by 
all application programs wishing to utilize the TIFF library functions. It takes 
care of all TIFF library function declarations so the programmer does not have 
to. See the "view.exe" example program for an example of how to utilize this 
interface file.</P>
<P align=justify>&nbsp;</P><B>
<P align=justify>TIFF.C</B> This file provides the basic TIFF file access 
functions required to read and write TIFF files. These functions are described 
in detail in Figure and are shown in Listing .</P>
<P align=justify>&nbsp;</P></DIR>
<P>1. Write a TIFF file from the image currently displayed on the VGA 
screen.</P>
<P>&nbsp;</P>
<DIR><I>
<P>Prototype</P></I>
<P align=justify>CompletionCodeWriteTIFFFile(char *FileName,unsigned 
BitsperSample, unsigned SamplesPerPixel,</P>
<P align=justify>unsigned ImageWidth, unsigned Imagelength);</P>
<P align=justify>&nbsp;</P>
<P align=justify>Where:</P>
<P align=justify>&nbsp;</P>
<P align=justify>"FileName" is the name of the TIFF output file to create. 
"FileName" must be a null terminated string of characters. Full path names are 
accepted. "FileName" does not require (or prohibit the use of) a file extension. 
Since this function calls "TIFFOpen", any file extension specified will be 
stripped and an extension of ".TIF" used instead.</P>
<P align=justify>&nbsp;</P></DIR>
<DIR>
<P align=justify>"SamplesPerPixel" controls whether an image is written as a 
single-or multiple-plane image. Normally, "SamplesPerPixel" equals 1, and the 
produced image is a single plane. If "SamplesPerPixel" is equal to 4, a 4-plane 
image is created. Multiple-plane images require much longer to read and write 
from/to a disk file because of the additional processing required. 
Multiple-plane images are supported only because "ZSoft's PC PaintBrush 4 + " 
reads and writes multiple-plane images.</P>
<P align=justify>&nbsp;</P>
<P align=justify>"BitsPerSample" should be 1 for black and white images, 4 for 
16-color gray-scale images, and 8 for 64-level gray-scale or 256-color images. 
</P>
<P align=justify>&nbsp;</P></DIR>
<DIR>
<P align=justify>ImageWidth &amp; Image Length describe the dimensions of the 
image to be written to the specified TIFF file. They should contain the maximum 
resolution of the display mode utilized to display the image. That is, 
"ImageWidth" should be either 320 or 640, and "ImageLength" should be either 200 
or 480.</P>
<P align=justify>&nbsp;</P></DIR>
<DIR></DIR><B>
<P align=justify>Operation:</P></B>
<P align=justify>&nbsp;</P>
<P align=justify>This function is not very flexible in its operation. It will 
support only the production of gray-scale and color images, not black and white 
images. From this you should not form the impression that the TIFF function 
library is incomplete. The limitation is in this function alone, not the 
function library. Black and white images are not supported because the digitizer 
does not produce single-bit-per-pixel images. All images, whether gray scale or 
color, regardless of the number of colors or gray levels, will be written out as 
a "palette" format TIFF file. This means a "ColorMap" also needs to be written 
to the output TIFF file so TIFF readers can recreate the original images. </P>
<P align=justify>This function begins by calling "TIFFOpen", passing it a 
filename and the write mode flag, "w". This function will create a TIFF file 
with the given name and prepare it for being written. "TIFFOpen" also performs 
hidden initialization of the TIFF directory that will eventually be written to 
disk as part of the TIFF image. Any previous directory information is erased, 
and various default values for certain tags are installed. See the file "io.c" 
for more information.</P>
<P align=justify>Once the TIFF output file is opened, the function 
"TIFFSetField" is called many times to place the important image parameters into 
the newly initialized directory structure. As a result, tags will be placed in 
the output file for "SubfileType", "ImageWidth", "ImageLength", the number of 
"BitsPerSample", the compression type (always LZW in this code), the palette 
photometric interpretation, the make, the artist, the host computer, the number 
of "SamplesPerPixel", the "X" resolution, the "Y" resolution, the single-plane 
planar configuration, and the resolution units. Basically, tags are created for 
all of the mandatory tags specified in the TIFF specification.</P>
<P align=justify>After these tags are written, memory is allocated for a single 
row of image data. This buffer will be filled from the display once for each 
row. The address of this buffer will be passed to the TIFF library functions. 
The TIFF functions will compress the data from this buffer using LZW compression 
and write it to the output file.</P>
<P align=justify>Once the number of bytes that make up a row of display data is 
known, the number of rows per strip can be calculated. You'll recall that the 
length of a strip should be approximately 8KB. This function uses the 8KB target 
to calculate how many rows should be used to make up a strip. With this figure 
known, a "RowsPerStrip" entry is placed in the TIFF directory for eventual 
placement in the output file. Some programs will require fewer rows per strip 
because of memory constraints. For these programs, reduce the number of 
"RowsPerStrip" accordingly.</P>
<P align=justify>Next, the VGA color registers are read in preparation for 
building a "ColorMap" structure that will be written to the output file. The 
number of entries in the "ColorMap", as you will recall, is controlled by the 
number of bits in a pixel and the number of samples that make up a pixel. If 
there are 4 bits per sample, the "ColorMap" should contain 16 total entries. If 
8 bits per sample are used, the "ColorMap" will contain 256 entries. This code 
is complicated by the fact that the 16-color VGA modes utilize a palette that 
adds a layer of indirection to the actual color register number. The 256-color 
VGA mode does not use a palette. Whether or not a palette is used, the 
"RedColorMap", "GreenColorMap", and "BlueColorMap" arrays are loaded with values 
from the VGA color registers. These will become the "ColorMap" structure in the 
TIFF file. (<I>Note:</I> the VGA color register values range from 0 to 63. The 
TIFF "ColorMap" values range from 0 to 65,535. For this reason, the values read 
from the VGA color register are multiplied by 1,024 before being placed in the 
"ColorMap".) Once the "ColorMap" is built, a directory entry is made for it.</P>
<P align=justify>Finally, the image raster data is read from the screen and 
passed to the TIFF library function "TIFFWriteScanline" for compression and 
storage. How the information is read from the screen and passed to the TIFF 
function is determined by the number of bits utilized for each pixel and the 
mode the VGA adapter is in. If the image being encoded is 640 pixels in width, 
the code knows that <B>4</B> bits per pixel are utilized, so it packs two 4-bit 
pixel values together into a single byte. These bytes are accumulated for a 
single row of the displayed image and then are written to disk. This process 
continues for each row of the displayed image. <B>A</B> similar process is used 
if the image being encoded is 320 pixels wide.</P>
<P align=justify>After all of the image data is written to the file, the 
function "TIFFClose" is called. This function causes all of the tags to be 
created from the internal directory structure (which defines the raster image) 
and written to disk. It then closes the output file. After that, all memory that 
was allocated for this function is freed, and control is returned to the calling 
application program.</P>
<P>&nbsp;</P>
<P align=justify>2. Read and display a TIFF file on the VGA screen.</P>
<P align=justify>&nbsp;</P>
<DIR><I>
<P align=justify>Prototype</P></I>
<P align=justify>CompletionCodeDisplayTIFFFile(char *FileName, unsigned 
Verbose);</P>
<P align=justify>&nbsp;</P>
<P align=justify>Where:</P>
<P align=justify>"FileName" is as explained above.</P>
<P align=justify>"Verbose" controls whether detailed information about the TIFF 
file structure should be displayed or not. In other words, if "Verbose" is TRUE, 
all of the tag information from the TIFF file will be displayed on the monitor 
before the actual image is displayed. If FALSE, the image only will be 
displayed.</P>
<P align=justify>&nbsp;</P></DIR><B>
<P align=justify>Operation:</P></B>
<P align=justify>The operation of this function is somewhat more 
straight-forward than the function just described. Its first action is to open 
the specified TIFF file. If the file is located, the "Verbose" flag is checked 
to see if a detailed dump of TIFF file information was requested. If so, the 
function "TIFFPrintDirectory" from the file "print.c" is called to display the 
TIFF tag information. Next, the function "TIFFGetField" is repeatedly called to 
check for the presence of required tags and to retrieve the tag information. If 
any of the required tags are not found, this function will abort operation after 
displaying an error message. If some of the tags that have default values are 
missing, a warning message is output but the operation continues.</P>
<P align=justify>From the image parameters retrieved from the TIFF file, the 
required VGA mode for image display can be deduced. Once the video mode is 
decided and selected, various VGA default palettes are loaded just in case a 
"ColorMap" is not found in the TIFF file. The VGA palette is overwritten when a 
"ColorMap" structure is read from the TIFF file. Once all this preparatory work 
is accomplished, the actual raster data is read from the file a strip at a time 
and presented to the display portion of this function on a row-by-row basis. 
Just as before, how the row data is displayed depends upon the number of bits 
utilized per pixel. A separate code segment is used to process images with 1, 4, 
or 8 bits per pixel.</P>
<P align=justify>After the image is displayed, all memory allocated by this 
function is freed, and the TIFF file is closed. Control is then returned to the 
calling code. The image will remain on the VGA display until another image 
overwrites it or text mode is again selected.</P>
<P align=justify>&nbsp;</P>
<P align=justify>The following is the contents of the file "tiffintf.h":</P><IMG 
src="The TIFF Image File Format_files/tiff3.gif" width="100%"> <IMG 
src="The TIFF Image File Format_files/tiff4.gif" width="100%"><IMG 
src="The TIFF Image File Format_files/tiff5.gif" width="100%"> <IMG 
src="The TIFF Image File Format_files/tiff6.gif" width="100%"><IMG 
src="The TIFF Image File Format_files/tiff7.gif" width="100%"> <IMG 
src="The TIFF Image File Format_files/tiff8.gif" width="100%"><IMG 
src="The TIFF Image File Format_files/tiff9.gif" width="100%"><IMG 
src="The TIFF Image File Format_files/tiff10.gif" width="100%"><IMG 
src="The TIFF Image File Format_files/tiff11.gif" width="100%"><IMG 
src="The TIFF Image File Format_files/tiff12.gif" width="100%"><IMG 
src="The TIFF Image File Format_files/tiff13.gif" width="100%"><IMG 
src="The TIFF Image File Format_files/tiff14.gif" width="100%"><IMG 
src="The TIFF Image File Format_files/tiff15.gif" width="100%"> <IMG 
src="The TIFF Image File Format_files/tiff16.gif" width="100%"><IMG 
src="The TIFF Image File Format_files/tiff17.gif" width="100%"><IMG 
src="The TIFF Image File Format_files/tiff18.gif" width="100%"><IMG 
src="The TIFF Image File Format_files/tiff19.gif" width="100%"> </FONT><FONT 
face="Times New Roman" size=5>
<P align=justify>Conclusion:</P></FONT><FONT face="Times New Roman">
<P align=justify>&nbsp;</P></FONT>
<TABLE borderColor=#000000 cellSpacing=2 cellPadding=11 width=624 border=1>
  <TBODY>
  <TR>
    <TD vAlign=top><FONT face="Times New Roman">
      <P>&nbsp;</P>
      <P>&nbsp;</P>
      <P>It is obviously very tedious to create a general all-purpose viewer. 
      Fortunately, you do not have to.</P>
      <P>&nbsp;</P></FONT><B><FONT face="Times New Roman" size=4>
      <P>You need only write those parts of a decoder which might be needed to 
      handle the types of TIFF files that you anticipate running into. Ignoring 
      tags is an important part of using the TIFF format.</P></B></FONT><FONT 
      face="Times New Roman">
      <P>&nbsp;</P>
      <P>Many files, especially those which come from a scanner, are loaded with 
      information which will be of no value to you (for example, the 
      manufacturer of the equipment). You can successfully decode TIFF files 
      without knowing this.</P>
      <P></FONT>&nbsp;</P></TD></TR></TBODY></TABLE><FONT face="Times New Roman">
<P align=justify>&nbsp;</P></FONT><FONT face="Times New Roman" size=5>
<P align=justify>The Good News:</P></FONT><FONT face="Times New Roman" size=3>
<P align=justify>&nbsp;</P>
<P align=justify>&nbsp;</P>
<P align=justify>Fortunately for us we can make some perfectly sensible but 
greatly simplifying assumptions. This is because we are "in charge" of both 
sides of the image reading/writing process and <I>we control completely how the 
TIFF file is composed</I>:</P>
<P align=justify>&nbsp;</P></FONT><B><FONT face="Times New Roman">
<P align=center>Simply issue an error message and cease processing in the 
following situations:</P></B></FONT><FONT face="Times New Roman" size=3>
<P align=justify>&nbsp;</P>
<DIR>
<P align=justify>

⌨️ 快捷键说明

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