LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 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 draw provides image composition functions. | 5 // Package draw provides image composition functions. |
6 // | 6 // |
7 // See "The Go image/draw package" for an introduction to this package: | 7 // See "The Go image/draw package" for an introduction to this package: |
8 // http://golang.org/doc/articles/image_draw.html | 8 // http://golang.org/doc/articles/image_draw.html |
9 package draw | 9 package draw |
10 | 10 |
11 import ( | 11 import ( |
12 "image" | 12 "image" |
13 "image/color" | 13 "image/color" |
14 ) | 14 ) |
15 | 15 |
16 // m is the maximum color value returned by image.Color.RGBA. | 16 // m is the maximum color value returned by image.Color.RGBA. |
17 const m = 1<<16 - 1 | 17 const m = 1<<16 - 1 |
18 | 18 |
19 // A draw.Image is an image.Image with a Set method to change a single pixel. | 19 // Image is an image.Image with a Set method to change a single pixel. |
20 type Image interface { | 20 type Image interface { |
21 image.Image | 21 image.Image |
22 Set(x, y int, c color.Color) | 22 Set(x, y int, c color.Color) |
| 23 } |
| 24 |
| 25 // Quantizer produces a palette for an image. |
| 26 type Quantizer interface { |
| 27 // Quantize appends up to cap(p) - len(p) colors to p and returns the |
| 28 // updated palette suitable for converting m to a paletted image. |
| 29 Quantize(p color.Palette, m image.Image) color.Palette |
23 } | 30 } |
24 | 31 |
25 // Op is a Porter-Duff compositing operator. | 32 // Op is a Porter-Duff compositing operator. |
26 type Op int | 33 type Op int |
27 | 34 |
28 const ( | 35 const ( |
29 // Over specifies ``(src in mask) over dst''. | 36 // Over specifies ``(src in mask) over dst''. |
30 Over Op = iota | 37 Over Op = iota |
31 // Src specifies ``src in mask''. | 38 // Src specifies ``src in mask''. |
32 Src | 39 Src |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 | 664 |
658 // Recycle the quantization error buffers. | 665 // Recycle the quantization error buffers. |
659 if floydSteinberg { | 666 if floydSteinberg { |
660 quantErrorCurr, quantErrorNext = quantErrorNext, quantEr
rorCurr | 667 quantErrorCurr, quantErrorNext = quantErrorNext, quantEr
rorCurr |
661 for i := range quantErrorNext { | 668 for i := range quantErrorNext { |
662 quantErrorNext[i] = [3]int32{} | 669 quantErrorNext[i] = [3]int32{} |
663 } | 670 } |
664 } | 671 } |
665 } | 672 } |
666 } | 673 } |
LEFT | RIGHT |