aboutsummaryrefslogtreecommitdiff
path: root/src/image
AgeCommit message (Collapse)Author
2015-07-11all: link to https instead of httpBrad Fitzpatrick
The one in misc/makerelease/makerelease.go is particularly bad and probably warrants rotating our keys. I didn't update old weekly notes, and reverted some changes involving test code for now, since we're late in the Go 1.5 freeze. Otherwise, the rest are all auto-generated changes, and all manually reviewed. Change-Id: Ia2753576ab5d64826a167d259f48a2f50508792d Reviewed-on: https://go-review.googlesource.com/12048 Reviewed-by: Rob Pike <r@golang.org>
2015-07-03image/draw: fix double-draw when the dst is paletted.Nigel Tao
The second (fallback) draw is a no-op, but it's a non-trivial amount of work. Fixes #11550. benchmark old ns/op new ns/op delta BenchmarkPaletted-4 16301219 7309568 -55.16% Change-Id: Ic88c537b2b0c710cf517888f3dd15cb702dd142f Reviewed-on: https://go-review.googlesource.com/11858 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-30image/gif: accept LZW encodings that do not have an explicit end marker.Nigel Tao
The spec says this is invalid, but it matches giflib's behavior. Fixes #9856 (together with https://go-review.googlesource.com/11661). Change-Id: I05701f62a9e5e724a2d85c6b87ae4111e537146b Reviewed-on: https://go-review.googlesource.com/11663 Reviewed-by: Rob Pike <r@golang.org>
2015-06-23image/gif: set default loop count to 0 when app ext. is not presentAndrew Bonventre
It was otherwise not being preserved across specific Decode->Encode->Decode calls. Fixes #11287 Change-Id: I40602da7fa39ec67403bed52ff403f361c6171bb Reviewed-on: https://go-review.googlesource.com/11256 Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-06-19image/gif: re-enable some invalid-palette tests.Nigel Tao
These tests were broken by https://go-review.googlesource.com/#/c/11227/ which fixed the LZW encoder to reject invalid input. For TestNoPalette, the LZW encoder with a litWidth of 2 now rejects an input byte of 128, so we change 128 to 3, as 3 <= (1<<2 - 1). For TestPixelOutsidePaletteRange, the LZW encoder similarly rejects an input byte of 255. Prior to golang.org/cl/11227, the encoder (again with a litWidth of 2) accepted the 255 input byte, but masked it with (1<<2 - 1), so that the 255 test case was effectively the same as the 3 test case. After that LZW CL, the 255 input byte is simply invalid, so we remove it as a test case. The test still tests pixels outside of the palette range, since 3 >= the length of the global palette, which is 2. Change-Id: I50be9623ace016740e34801549c15f83671103eb Reviewed-on: https://go-review.googlesource.com/11273 Reviewed-by: David Symonds <dsymonds@golang.org>
2015-06-18image/gif: return an error on missing paletteJeff R. Allen
A frame that tries to use the global palette when it has not been given should result in an error, not an image with no palette at all. Fixes #11150. Change-Id: If0c3a201a0ac977eee2b7a5dc68930c0c5787f40 Reviewed-on: https://go-review.googlesource.com/11064 Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-06-18image/gif: (temporarily) disable broken tests.Nigel Tao
The compress/lzw encoder now rejects too-large input bytes, as of https://go-review.googlesource.com/#/c/11227/, so we can't generate bad GIFs programatically. Change-Id: I0b32ce8e1f1776cd6997869db61e687430464e45 Reviewed-on: https://go-review.googlesource.com/11270 Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-06-18all: switch to the new deprecation conventionShenghou Ma
While we're at it, move some misplaced comment blocks around. Change-Id: I1847d7f1ca1dbb8e5de737203c4ed6c66e112508 Reviewed-on: https://go-review.googlesource.com/10188 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2015-05-06image/gif: allow encoding a single-frame image whose top-left cornerNigel Tao
isn't (0, 0). Also fix a s/b.Min.X/b.Max.X/ typo in bounds checking. Fixes #10676 Change-Id: Ie5ff7ec20ca30367a8e65d32061959a2d8e089e9 Reviewed-on: https://go-review.googlesource.com/9712 Reviewed-by: Rob Pike <r@golang.org>
2015-05-05image/gif: be consistent wrt "color map" or "color table" names.Nigel Tao
The spec at http://www.w3.org/Graphics/GIF/spec-gif89a.txt always says "color table" and not "color map". Change-Id: I4c172e3ade15618cbd616629822ce7d109a200af Reviewed-on: https://go-review.googlesource.com/9668 Reviewed-by: Rob Pike <r@golang.org>
2015-05-04image/gif: don't encode local color tables if they're the same as theNigel Tao
global color table. Change-Id: Ia38f75708ed5e5b430680a1eecafb4fc8047269c Reviewed-on: https://go-review.googlesource.com/9467 Reviewed-by: Rob Pike <r@golang.org>
2015-04-29image/gif: check that individual frame's bounds are within the overallNigel Tao
GIF's bounds. Also change the implicit Config Width and Height to be the Rectangle.Max, not the Dx and Dy, of the first frame's bounds. For the case where the first frame's bounds is something like (5,5)-(8,8), the overall width should be 8, not 3. Change-Id: I3affc484f5e32941a36f15517a92ca8d189d9c22 Reviewed-on: https://go-review.googlesource.com/9465 Reviewed-by: Rob Pike <r@golang.org>
2015-04-28image/gif: encode disposal, bg index and Config.Nigel Tao
The previous CL implemented decoding, but not encoding. Also return the global color map (if present) for DecodeConfig. Change-Id: I3b99c93720246010c9fe0924dc40a67875dfc852 Reviewed-on: https://go-review.googlesource.com/9389 Reviewed-by: Rob Pike <r@golang.org>
2015-04-23image/png: don't silently swallow io.ReadFull's io.EOF error when itNigel Tao
lands exactly on an IDAT row boundary. Fixes #10493 Change-Id: I12be7c5bdcde7032e17ed1d4400db5f17c72bc87 Reviewed-on: https://go-review.googlesource.com/9270 Reviewed-by: Rob Pike <r@golang.org>
2015-04-23image/jpeg: have the LargeImageWithShortData test only allocate 64 MiB, not 604Nigel Tao
MiB. Fixes #10531 Change-Id: I9eece86837c3df2b1f7df315d5ec94bd3ede3eec Reviewed-on: https://go-review.googlesource.com/9238 Run-TryBot: Nigel Tao <nigeltao@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2015-04-22image/jpeg: ensure that we can't unread a byte if we didn't read a byte.Nigel Tao
Fixes #10413 Change-Id: I7a4ecd042c40f786ea7406c670d561b1c1179bf0 Reviewed-on: https://go-review.googlesource.com/8998 Reviewed-by: Rob Pike <r@golang.org>
2015-04-16image/color: have Palette.Index honor alpha for closest match, not justNigel Tao
red, green and blue. Fixes #9902 Change-Id: Ibffd0aa2f98996170e39a919296f69e9d5c71545 Reviewed-on: https://go-review.googlesource.com/8907 Reviewed-by: Rob Pike <r@golang.org>
2015-04-16image: spell coordinate consistently, without the hyphen.Nigel Tao
Change-Id: I211c0d33dc292c6a703d788f6d4d286107bcb6b0 Reviewed-on: https://go-review.googlesource.com/8906 Reviewed-by: Rob Pike <r@golang.org>
2015-04-15image/png: reject multiple tRNS chunks.Nigel Tao
http://www.w3.org/TR/PNG/#5ChunkOrdering disallows them. Fixes #10423 Change-Id: I3399ce53dc8b41b1b5f0b906a5912e6efd80418f Reviewed-on: https://go-review.googlesource.com/8905 Reviewed-by: Rob Pike <r@golang.org>
2015-04-14image/jpeg: don't assume that an ensureNBits failure implies that we canNigel Tao
call unreadByteStuffedByte. If ensureNBits was due to an io.EOF that was translated to jpeg.errShortHuffmanData, then we may have read no bytes, so there is no byte-stuffed-byte to unread. Fixes #10387 Change-Id: I39a3842590c6cef2aa48943288d52f603338b44d Reviewed-on: https://go-review.googlesource.com/8841 Reviewed-by: Rob Pike <r@golang.org>
2015-04-13image/gif: expose disposal, bg index and ConfigColin Kennedy
The background index in the global palette (located in the image.Config) is necessary for interpreting GIF frames properly Frame disposal information is necessary for interpreting GIF frames in the context of a sequence (or animation) Removes decoder.flags as it can be a local variable Change-Id: I6790a7febf6ba0859175c834c807bc6413e6b194 Reviewed-on: https://go-review.googlesource.com/4620 Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-04-09image/jpeg: reject multiple Start-Of-Frame markers.Nigel Tao
Fixes #10389 Change-Id: Id1c687122751f9317041d9e425d03b267a26c6de Reviewed-on: https://go-review.googlesource.com/8681 Reviewed-by: Rob Pike <r@golang.org>
2015-04-08image/color: have CMYK.RGBA work in 16-bit color, per the Color interface.Nigel Tao
Change-Id: I3621527c924a43724032f80a072505c60d929ab3 Reviewed-on: https://go-review.googlesource.com/8180 Reviewed-by: Rob Pike <r@golang.org>
2015-03-27image/draw: fix golden test for YCbCr.RGBA change.Nigel Tao
The previous change was https://go-review.googlesource.com/#/c/8073/ Change-Id: I0c48502d1ba90fb5d41c5e66346a8e7f4ee87ce7 Reviewed-on: https://go-review.googlesource.com/8151 Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-03-26image/color: have YCbCr.RGBA work in 16-bit color, per the ColorNigel Tao
interface. Change-Id: Ie025753df08ae93e7a5095a3426aff15fa2016fd Reviewed-on: https://go-review.googlesource.com/8073 Reviewed-by: Rob Pike <r@golang.org>
2015-03-25image/internal/imageutil: inline the color.YCbCrToRGB calls.Nigel Tao
The image/draw benchmark: benchmark old ns/op new ns/op delta BenchmarkYCbCr 1198605 978647 -18.35% Change-Id: Iacfc21e6f641ecb05adc00b3aec0048f1f43d265 Reviewed-on: https://go-review.googlesource.com/7952 Reviewed-by: Rob Pike <r@golang.org>
2015-03-24image/internal/imageutil: generate subsample-ratio-specific code.Nigel Tao
This is in preparation for inlining the color.YCbCrToRGB calls in a follow-up change. Change-Id: I30750ace11a8ef6016b3c1e0b4bfdbcc8151f9a5 Reviewed-on: https://go-review.googlesource.com/7951 Reviewed-by: Rob Pike <r@golang.org>
2015-03-23image/internal/imageutil: new package, used by image/draw and image/jpeg.Nigel Tao
The imageutil.DrawYCbCr function lives in an internal package because it is needed by both the image/draw and image/jpeg packages, but it doesn't seem right for one of those two to depend on the other. It could eventually go into the image package, but that would require committing to an API for the rest of Go 1.x. Change-Id: I7b12555c970d86409365e99eef9360702aaffa30 Reviewed-on: https://go-review.googlesource.com/7925 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2015-03-21image/color: add alpha-premultiplied comment.Nigel Tao
Change-Id: I9968f53a8286a0e5ccc197a9b5fae499e2f95326 Reviewed-on: https://go-review.googlesource.com/7790 Reviewed-by: Rob Pike <r@golang.org>
2015-03-13image/jpeg: reject bad Tq values in SOF data.Nigel Tao
Fixes #10154 Change-Id: Ibb8ea9bcf512e7639c57a6f17afbe4495fa329cd Reviewed-on: https://go-review.googlesource.com/7494 Reviewed-by: Minux Ma <minux@golang.org>
2015-03-11image/jpeg: support chroma hv values other than 0x11.Nigel Tao
The testdata was generated by: convert video-001.png tmp1.tga cjpeg -quality 100 -sample 2x2,1x2,1x2 tmp1.tga > video-001.221212.jpeg djpeg -nosmooth -targa video-001.221212.jpeg > tmp2.tga convert tmp2.tga video-001.221212.png rm tmp1.tga tmp2.tga Change-Id: Ica241dfc19b3eb47ade150bf0432373c6006c38a Reviewed-on: https://go-review.googlesource.com/7264 Reviewed-by: Rob Pike <r@golang.org>
2015-03-09image/jpeg: support RGB JPEG images.Nigel Tao
The testdata was generated by: convert video-001.png tmp1.tga cjpeg -rgb -sample 2x2,1x1,1x1 tmp1.tga > video-001.rgb.jpeg djpeg -nosmooth -targa video-001.rgb.jpeg > tmp2.tga convert tmp2.tga video-001.rgb.png rm tmp1.tga tmp2.tga Change-Id: I5da0591b9005c1c75e807311f157d385e0e20a38 Reviewed-on: https://go-review.googlesource.com/6910 Reviewed-by: Rob Pike <r@golang.org>
2015-03-04image/jpeg: check for component uniqueness and total sampling factors.Nigel Tao
Change-Id: I83de9d83708edc8d196bbcfdc7d2ba7ffaff50d2 Reviewed-on: https://go-review.googlesource.com/6586 Reviewed-by: Rob Pike <r@golang.org>
2015-03-04image: make Rectangle implement Image.Nigel Tao
Change-Id: I01e328fc3644b679bacf2209c3d7ade9d8bffe53 Reviewed-on: https://go-review.googlesource.com/6551 Reviewed-by: Rob Pike <r@golang.org>
2015-03-03image/jpeg: when following component selectors, only consider validNigel Tao
components. This fixes decoding JPEG images where the component selector is 0. Such images are rare, but not impossible. Change-Id: I6d221bce01cce8cc0440e117543233371782ca22 Reviewed-on: https://go-review.googlesource.com/6421 Reviewed-by: Rob Pike <r@golang.org>
2015-03-02image/jpeg: distinguish between FormatError and UnsupportedError whenNigel Tao
encountering unknown markers. Change-Id: Ica86013308d69da2f5b486119235ff693135b2f1 Reviewed-on: https://go-review.googlesource.com/6393 Reviewed-by: David Symonds <dsymonds@golang.org> Run-TryBot: David Symonds <dsymonds@golang.org>
2015-02-28image/draw: add a fast path for Gray src images.Nigel Tao
Grayscale PNG and JPEG images are not uncommon. We should have a fast path. Also add a benchmark for the recently added CMYK fast path. benchmark old ns/op new ns/op delta BenchmarkGray 13960348 324152 -97.68% Change-Id: I72b5838c8c3d1f2d0a4536a848e020e80b10c0f7 Reviewed-on: https://go-review.googlesource.com/6237 Reviewed-by: Rob Pike <r@golang.org>
2015-02-28image/draw: optimize drawFillSrc.Nigel Tao
benchmark old ns/op new ns/op delta BenchmarkFillSrc 46781 46000 -1.67% Change-Id: I0ab25d42d5763f1a0fe5a67ee00b83f0aa55f1f6 Reviewed-on: https://go-review.googlesource.com/6235 Reviewed-by: Rob Pike <r@golang.org>
2015-02-26image/jpeg: support 4:1:1 and 4:1:0 chroma subsampling.Nigel Tao
The test data was generated by: convert video-001.png tmp.tga cjpeg -quality 50 -sample 4x2,1x1,1x1 tmp.tga > video-001.q50.410.jpeg cjpeg -quality 50 -sample 4x1,1x1,1x1 tmp.tga > video-001.q50.411.jpeg cjpeg -quality 50 -sample 4x2,1x1,1x1 -progressive tmp.tga > video-001.q50.410.progressive.jpeg cjpeg -quality 50 -sample 4x1,1x1,1x1 -progressive tmp.tga > video-001.q50.411.progressive.jpeg rm tmp.tga Change-Id: I5570389c462360f98c3160f3c6963d9466d511de Reviewed-on: https://go-review.googlesource.com/6041 Reviewed-by: Rob Pike <r@golang.org>
2015-02-26image: add YCbCrSubsampleRatio411 and YCbCrSubsampleRatio410.Nigel Tao
Some real world JPEG images are in 4:1:1 and 4:1:0 formats. See also http://en.wikipedia.org/wiki/Chroma_subsampling Change-Id: I2d51a41944f581cf11f4ab975046b1737271842f Reviewed-on: https://go-review.googlesource.com/5838 Reviewed-by: Rob Pike <r@golang.org>
2015-02-19image/jpeg: support 16-bit quantization tables and Extended SequentialNigel Tao
frames. Fixes #9888. Change-Id: I60f1d843e72e1b7bc77ab984f149c9ddb5258a06 Reviewed-on: https://go-review.googlesource.com/5251 Reviewed-by: Rob Pike <r@golang.org>
2015-02-18image: change Rectangle.Eq to return true for all empty rectangles, evenNigel Tao
if their nominal Min and Max points differ. This is a behavior change, but arguably a bug fix, as Eq wasn't previously consistent with In, and the concept of a rectangle being a set of points. This is demonstrated by the new geom_test.go test. It does mean that r.Eq(s) no longer implies that Inset'ting both r and s with a negative inset results in two rectangles that are still Eq, but that seems acceptable to me. The previous behavior is still available as "r == s". Also clarify the image.Rect doc comment when the inputs are non-canonical. Also simplify the Point and Rectangle Eq implementations dating from before Go 1.0, when you couldn't compare structs via the == operator. Change-Id: Ic39e628db31dc5fe5220f4b444e6d5000eeace5b Reviewed-on: https://go-review.googlesource.com/5006 Reviewed-by: Rob Pike <r@golang.org>
2015-02-17image/draw: add CMYK fast path.Nigel Tao
Change-Id: I9582aff7ca141a8aead5692af74b9c708b1700cc Reviewed-on: https://go-review.googlesource.com/5020 Reviewed-by: Rob Pike <r@golang.org>
2015-02-17image: fix Rectangle.Overlaps and Rectangle.Union for empty rectangles.Nigel Tao
Fixes #9895. Change-Id: I37d78ced9ff8196e32d299504908a1c41ad4592d Reviewed-on: https://go-review.googlesource.com/4990 Reviewed-by: Rob Pike <r@golang.org>
2015-02-17image/draw: add CMYK test.Nigel Tao
This just adds test cases. Optimizing CMYK draws will be a follow-up change. Change-Id: Ic0d6343d420cd021e21f88623ad7182e93017da9 Reviewed-on: https://go-review.googlesource.com/4941 Reviewed-by: Rob Pike <r@golang.org>
2015-02-16image/jpeg: remove the (temporary) dependency on image/draw.Nigel Tao
Change-Id: Idd66f9c3c9eaa4ff1f950fb90e4800dc625dec08 Reviewed-on: https://go-review.googlesource.com/4916 Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-02-16image/jpeg: support decoding CMYK and YCbCrK images.Nigel Tao
The new testdata was created by: convert video-001.png -colorspace cmyk video-001.cmyk.jpeg video-001.cmyk.jpeg was then converted back to video-001.cmyk.png via the GIMP. ImageMagick (convert) wasn't used for this second conversion because IM's default color profiles complicates things. Fixes #4500. Change-Id: Ibf533f6a6c7e76883acc493ce3a4289d7875df3f Reviewed-on: https://go-review.googlesource.com/4801 Reviewed-by: Rob Pike <r@golang.org>
2015-02-16image: add image.CMYK and color.CMYK types.Nigel Tao
Change-Id: Icf212a4b890725c803b16e76e1a88294b8b62cb8 Reviewed-on: https://go-review.googlesource.com/4800 Reviewed-by: Rob Pike <r@golang.org>
2015-02-06image: fix obsolete reference in PalettedImage doc commentAndrew Ekstedt
PalettedColorModel was renamed to color.Palette over three years ago by https://golang.org/cl/5132048. Change-Id: I0204ade10eabff45620fda2990fed428c65d871e Reviewed-on: https://go-review.googlesource.com/3305 Reviewed-by: Minux Ma <minux@golang.org> Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-01-25image: fix typo in Alpha16 doc commentAndrew Ekstedt
Change-Id: Ie7031ae37f52ea1f229bfb769daf306d537b3d3e Reviewed-on: https://go-review.googlesource.com/3300 Reviewed-by: Minux Ma <minux@golang.org>