Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
de7c28fe
Commit
de7c28fe
authored
May 16, 2011
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
image/gif: enable images with <8 bits per pixel.
R=nigeltao CC=golang-dev
https://golang.org/cl/4552042
parent
ff109385
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
5 deletions
+3
-5
decode_test.go
src/pkg/image/decode_test.go
+1
-0
reader.go
src/pkg/image/gif/reader.go
+2
-5
video-001.5bpp.gif
src/pkg/image/testdata/video-001.5bpp.gif
+0
-0
No files found.
src/pkg/image/decode_test.go
View file @
de7c28fe
...
...
@@ -30,6 +30,7 @@ var imageTests = []imageTest{
// to GIF loses significant image quality.
{
"testdata/video-001.gif"
,
64
<<
8
},
{
"testdata/video-001.interlaced.gif"
,
64
<<
8
},
{
"testdata/video-001.5bpp.gif"
,
128
<<
8
},
// JPEG is a lossy format and hence needs a non-zero tolerance.
{
"testdata/video-001.jpeg"
,
8
<<
8
},
{
"testdata/video-001.png"
,
0
},
...
...
src/pkg/image/gif/reader.go
View file @
de7c28fe
...
...
@@ -173,11 +173,10 @@ Loop:
if
err
!=
nil
{
return
err
}
if
litWidth
>
8
{
if
litWidth
<
2
||
litWidth
>
8
{
return
fmt
.
Errorf
(
"gif: pixel size in decode out of range: %d"
,
litWidth
)
}
// A wonderfully Go-like piece of magic. Unfortunately it's only at its
// best for 8-bit pixels.
// A wonderfully Go-like piece of magic.
lzwr
:=
lzw
.
NewReader
(
&
blockReader
{
r
:
d
.
r
},
lzw
.
LSB
,
int
(
litWidth
))
if
_
,
err
=
io
.
ReadFull
(
lzwr
,
m
.
Pix
);
err
!=
nil
{
break
...
...
@@ -379,7 +378,6 @@ func (d *decoder) uninterlace(m *image.Paletted) {
// Decode reads a GIF image from r and returns the first embedded
// image as an image.Image.
// Limitation: The file must be 8 bits per pixel.
func
Decode
(
r
io
.
Reader
)
(
image
.
Image
,
os
.
Error
)
{
var
d
decoder
if
err
:=
d
.
decode
(
r
,
false
);
err
!=
nil
{
...
...
@@ -397,7 +395,6 @@ type GIF struct {
// DecodeAll reads a GIF image from r and returns the sequential frames
// and timing information.
// Limitation: The file must be 8 bits per pixel.
func
DecodeAll
(
r
io
.
Reader
)
(
*
GIF
,
os
.
Error
)
{
var
d
decoder
if
err
:=
d
.
decode
(
r
,
false
);
err
!=
nil
{
...
...
src/pkg/image/testdata/video-001.5bpp.gif
0 → 100644
View file @
de7c28fe
6.07 KB
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment