github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/image/tiff/consts.go (about) 1 // Copyright 2011 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package tiff 6 7 // A tiff image file contains one or more images. The metadata 8 // of each image is contained in an Image File Directory (IFD), 9 // which contains entries of 12 bytes each and is described 10 // on page 14-16 of the specification. An IFD entry consists of 11 // 12 // - a tag, which describes the signification of the entry, 13 // - the data type and length of the entry, 14 // - the data itself or a pointer to it if it is more than 4 bytes. 15 // 16 // The presence of a length means that each IFD is effectively an array. 17 18 const ( 19 leHeader = "II\x2A\x00" // Header for little-endian files. 20 beHeader = "MM\x00\x2A" // Header for big-endian files. 21 22 ifdLen = 12 // Length of an IFD entry in bytes. 23 ) 24 25 // Data types (p. 14-16 of the spec). 26 const ( 27 dtByte = 1 28 dtASCII = 2 29 dtShort = 3 30 dtLong = 4 31 dtRational = 5 32 ) 33 34 // The length of one instance of each data type in bytes. 35 var lengths = [...]uint32{0, 1, 1, 2, 4, 8} 36 37 // Tags (see p. 28-41 of the spec). 38 const ( 39 tImageWidth = 256 40 tImageLength = 257 41 tBitsPerSample = 258 42 tCompression = 259 43 tPhotometricInterpretation = 262 44 45 tStripOffsets = 273 46 tSamplesPerPixel = 277 47 tRowsPerStrip = 278 48 tStripByteCounts = 279 49 50 tTileWidth = 322 51 tTileLength = 323 52 tTileOffsets = 324 53 tTileByteCounts = 325 54 55 tXResolution = 282 56 tYResolution = 283 57 tResolutionUnit = 296 58 59 tPredictor = 317 60 tColorMap = 320 61 tExtraSamples = 338 62 tSampleFormat = 339 63 ) 64 65 // Compression types (defined in various places in the spec and supplements). 66 const ( 67 cNone = 1 68 cCCITT = 2 69 cG3 = 3 // Group 3 Fax. 70 cG4 = 4 // Group 4 Fax. 71 cLZW = 5 72 cJPEGOld = 6 // Superseded by cJPEG. 73 cJPEG = 7 74 cDeflate = 8 // zlib compression. 75 cPackBits = 32773 76 cDeflateOld = 32946 // Superseded by cDeflate. 77 ) 78 79 // Photometric interpretation values (see p. 37 of the spec). 80 const ( 81 pWhiteIsZero = 0 82 pBlackIsZero = 1 83 pRGB = 2 84 pPaletted = 3 85 pTransMask = 4 // transparency mask 86 pCMYK = 5 87 pYCbCr = 6 88 pCIELab = 8 89 ) 90 91 // Values for the tPredictor tag (page 64-65 of the spec). 92 const ( 93 prNone = 1 94 prHorizontal = 2 95 ) 96 97 // Values for the tResolutionUnit tag (page 18). 98 const ( 99 resNone = 1 100 resPerInch = 2 // Dots per inch. 101 resPerCM = 3 // Dots per centimeter. 102 ) 103 104 // imageMode represents the mode of the image. 105 type imageMode int 106 107 const ( 108 mBilevel imageMode = iota 109 mPaletted 110 mGray 111 mGrayInvert 112 mRGB 113 mRGBA 114 mNRGBA 115 ) 116 117 // CompressionType describes the type of compression used in Options. 118 type CompressionType int 119 120 const ( 121 Uncompressed CompressionType = iota 122 Deflate 123 ) 124 125 // specValue returns the compression type constant from the TIFF spec that 126 // is equivalent to c. 127 func (c CompressionType) specValue() uint32 { 128 switch c { 129 case Deflate: 130 return cDeflate 131 } 132 return cNone 133 }