LEFT | RIGHT |
1 // Copyright 2012 The Go Authors. All rights reserved. | 1 // Copyright 2012 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package tiff | 5 package tiff |
6 | 6 |
7 import ( | 7 import ( |
8 "encoding/binary" | 8 "encoding/binary" |
9 "image" | 9 "image" |
10 "io" | 10 "io" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 Compression CompressionType | 146 Compression CompressionType |
147 // Predictor determines whether a differencing predictor is used; | 147 // Predictor determines whether a differencing predictor is used; |
148 // if true, instead of each pixel's color, the color difference to the | 148 // if true, instead of each pixel's color, the color difference to the |
149 // preceding one is saved. This improves the compression for certain | 149 // preceding one is saved. This improves the compression for certain |
150 // types of images and compressors. For example, it works well for | 150 // types of images and compressors. For example, it works well for |
151 // photos with Deflate compression. | 151 // photos with Deflate compression. |
152 Predictor bool | 152 Predictor bool |
153 } | 153 } |
154 | 154 |
155 // Encode writes the image m to w. opt determines the options used for | 155 // Encode writes the image m to w. opt determines the options used for |
156 // encoding, such as the compression type. If it is nil, an uncompressed | 156 // encoding, such as the compression type. If opt is nil, an uncompressed |
157 // image is written. | 157 // image is written. |
158 func Encode(w io.Writer, m image.Image, opt *Options) error { | 158 func Encode(w io.Writer, m image.Image, opt *Options) error { |
159 predictor := false | 159 predictor := false |
160 compression := Uncompressed | 160 compression := Uncompressed |
161 if opt != nil { | 161 if opt != nil { |
162 predictor = opt.Predictor | 162 predictor = opt.Predictor |
163 compression = opt.Compression | 163 compression = opt.Compression |
164 } | 164 } |
165 if compression != Uncompressed || predictor { | 165 if compression != Uncompressed || predictor { |
166 return UnsupportedError("compression type") | 166 return UnsupportedError("compression type") |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 {tRowsPerStrip, dtShort, []uint32{uint32(height)}}, | 208 {tRowsPerStrip, dtShort, []uint32{uint32(height)}}, |
209 {tStripByteCounts, dtLong, []uint32{uint32(imageLen)}}, | 209 {tStripByteCounts, dtLong, []uint32{uint32(imageLen)}}, |
210 // There is currently no support for storing the image | 210 // There is currently no support for storing the image |
211 // resolution, so give a bogus value of 72x72 dpi. | 211 // resolution, so give a bogus value of 72x72 dpi. |
212 {tXResolution, dtRational, []uint32{72, 1}}, | 212 {tXResolution, dtRational, []uint32{72, 1}}, |
213 {tYResolution, dtRational, []uint32{72, 1}}, | 213 {tYResolution, dtRational, []uint32{72, 1}}, |
214 {tResolutionUnit, dtShort, []uint32{resPerInch}}, | 214 {tResolutionUnit, dtShort, []uint32{resPerInch}}, |
215 {tExtraSamples, dtShort, []uint32{extrasamples}}, | 215 {tExtraSamples, dtShort, []uint32{extrasamples}}, |
216 }) | 216 }) |
217 } | 217 } |
LEFT | RIGHT |