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

GetField() public method

Gets the value(s) of a tag in an open TIFF file.

GetField returns the value(s) of a tag or pseudo-tag associated with the current directory of the opened TIFF file. The tag is identified by tag. The type and number of values returned is dependent on the tag being requested. You may want to consult "Well-known tags and their value(s) data types" to become familiar with exact data types and calling conventions required for each tag supported by the library.

A pseudo-tag is a parameter that is used to control the operation of the library but whose value is not read or written to the underlying file.

public GetField ( TiffTag tag ) : BitMiracle.LibTiff.Classic.FieldValue[]
tag TiffTag The tag.
return BitMiracle.LibTiff.Classic.FieldValue[]
        public FieldValue[] GetField(TiffTag tag)
        {
            TiffFieldInfo fip = FindFieldInfo(tag, TiffType.ANY);
            if (fip != null && (isPseudoTag(tag) || fieldSet(fip.Bit)))
                return m_tagmethods.GetField(this, tag);

            return null;
        }

Usage Example

示例#1
0
        public bool tiffcvt(Tiff inImage, Tiff outImage)
        {
            FieldValue[] result = inImage.GetField(TiffTag.IMAGEWIDTH);
            if (result == null)
                return false;
            int width = result[0].ToInt();

            result = inImage.GetField(TiffTag.IMAGELENGTH);
            if (result == null)
                return false;
            int height = result[0].ToInt();

            copyField(inImage, outImage, TiffTag.SUBFILETYPE);
            outImage.SetField(TiffTag.IMAGEWIDTH, width);
            outImage.SetField(TiffTag.IMAGELENGTH, height);
            outImage.SetField(TiffTag.BITSPERSAMPLE, 8);
            outImage.SetField(TiffTag.COMPRESSION, m_compression);
            outImage.SetField(TiffTag.PHOTOMETRIC, Photometric.RGB);

            copyField(inImage, outImage, TiffTag.FILLORDER);
            outImage.SetField(TiffTag.ORIENTATION, Orientation.TOPLEFT);

            if (m_noAlpha)
                outImage.SetField(TiffTag.SAMPLESPERPIXEL, 3);
            else
                outImage.SetField(TiffTag.SAMPLESPERPIXEL, 4);

            if (!m_noAlpha)
            {
                short[] v = new short[1];
                v[0] = (short)ExtraSample.ASSOCALPHA;
                outImage.SetField(TiffTag.EXTRASAMPLES, 1, v);
            }

            copyField(inImage, outImage, TiffTag.XRESOLUTION);
            copyField(inImage, outImage, TiffTag.YRESOLUTION);
            copyField(inImage, outImage, TiffTag.RESOLUTIONUNIT);
            outImage.SetField(TiffTag.PLANARCONFIG, PlanarConfig.CONTIG);

            if (!m_testFriendly)
                outImage.SetField(TiffTag.SOFTWARE, Tiff.GetVersion());

            copyField(inImage, outImage, TiffTag.DOCUMENTNAME);
            
            if (m_processByBlock && inImage.IsTiled())
                return cvt_by_tile(inImage, outImage, width, height);
            else if (m_processByBlock)
                return cvt_by_strip(inImage, outImage, width, height);

            return cvt_whole_image(inImage, outImage, width, height);
        }
All Usage Examples Of BitMiracle.LibTiff.Classic.Tiff::GetField
Tiff