BitMiracle.LibTiff.Classic.Tiff.Open C# (CSharp) Method

Open() public static method

Initializes new instance of Tiff class and opens a TIFF file for reading or writing.

Open(string, string) opens a TIFF file whose name is fileName. When a file is opened for appending, existing data will not be touched; instead new data will be written as additional subfiles. If an existing file is opened for writing, all previous data is overwritten.

If a file is opened for reading, the first TIFF directory in the file is automatically read (see SetDirectory for reading directories other than the first). If a file is opened for writing or appending, a default directory is automatically created for writing subsequent data. This directory has all the default values specified in TIFF Revision 6.0: BitsPerSample = 1, ThreshHolding = Threshold.BILEVEL (bilevel art scan), FillOrder = MSB2LSB (most significant bit of each data byte is filled first), Orientation = TOPLEFT (the 0th row represents the visual top of the image, and the 0th column represents the visual left hand side), SamplesPerPixel = 1, RowsPerStrip = infinity, ResolutionUnit = INCH, and Compression = NONE. To alter these values, or to define values for additional fields, SetField must be used.

The mode parameter can include the following flags in addition to the "r", "w", and "a" flags. Note however that option flags must follow the read-write-append specification.

FlagDescription l When creating a new file force information be written with Little-Endian byte order (but see below). b When creating a new file force information be written with Big-Endian byte order (but see below). L Force image data that is read or written to be treated with bits filled from Least Significant Bit (LSB) to Most Significant Bit (MSB). Note that this is the opposite to the way the library has worked from its inception. B Force image data that is read or written to be treated with bits filled from Most Significant Bit (MSB) to Least Significant Bit (LSB); this is the default. H Force image data that is read or written to be treated with bits filled in the same order as the native CPU. C Enable the use of "strip chopping" when reading images that are comprised of a single strip or tile of uncompressed data. Strip chopping is a mechanism by which the library will automatically convert the single-strip image to multiple strips, each of which has about 8 Kilobytes of data. This facility can be useful in reducing the amount of memory used to read an image because the library normally reads each strip in its entirety. Strip chopping does however alter the apparent contents of the image because when an image is divided into multiple strips it looks as though the underlying file contains multiple separate strips. The default behaviour is to enable strip chopping. c Disable the use of strip chopping when reading images. h Read TIFF header only, do not load the first image directory. That could be useful in case of the broken first directory. We can open the file and proceed to the other directories.

By default the library will create new files with the native byte-order of the CPU on which the application is run. This ensures optimal performance and is portable to any application that conforms to the TIFF specification. To force the library to use a specific byte-order when creating a new file the "b" and "l" option flags may be included in the mode parameter; for example, "wb" or "wl".

The use of the "l" and "b" flags is strongly discouraged. These flags are provided solely because numerous vendors do not correctly support TIFF; they only support one of the two byte orders. It is strongly recommended that you not use this feature except to deal with busted apps that write invalid TIFF.

The "L", "B", and "H" flags are intended for applications that can optimize operations on data by using a particular bit order. By default the library returns data in MSB2LSB bit order. Returning data in the bit order of the native CPU makes the most sense but also requires applications to check the value of the TiffTag.FILLORDER tag; something they probably do not do right now.

The "c" option permits applications that only want to look at the tags, for example, to get the unadulterated TIFF tag information.

public static Open ( string fileName, string mode ) : Tiff
fileName string The name of the file to open.
mode string The open mode. Specifies if the file is to be opened for /// reading ("r"), writing ("w"), or appending ("a") and, optionally, whether to override /// certain default aspects of library operation (see remarks).
return Tiff
        public static Tiff Open(string fileName, string mode)
        {
            return Tiff.Open(fileName, mode, null, null);
        }

Usage Example

示例#1
0
 static Tiff Open(string fileName, string mode, TiffErrorHandler errorHandler)
 {
     return(Tiff.Open(fileName, mode, errorHandler, null));
 }
Tiff