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
a6f95ad3
Commit
a6f95ad3
authored
Jul 18, 2013
by
Andrew Bonventre
Committed by
Nigel Tao
Jul 18, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
image/gif: don't write superfluous global color table
R=r, nigeltao CC=golang-dev
https://golang.org/cl/11446043
parent
c5c52f07
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
11 deletions
+4
-11
writer.go
src/pkg/image/gif/writer.go
+4
-11
No files found.
src/pkg/image/gif/writer.go
View file @
a6f95ad3
...
...
@@ -52,9 +52,6 @@ type encoder struct {
err
error
// g is a reference to the data that is being encoded.
g
*
GIF
// bitsPerPixel is the number of bits required to represent each color
// in the image.
bitsPerPixel
int
// buf is a scratch buffer. It must be at least 768 so we can write the color map.
buf
[
1024
]
byte
}
...
...
@@ -118,23 +115,19 @@ func (e *encoder) writeHeader() {
return
}
// TODO: This bases the global color table on the first image
// only.
pm
:=
e
.
g
.
Image
[
0
]
// Logical screen width and height.
writeUint16
(
e
.
buf
[
0
:
2
],
uint16
(
pm
.
Bounds
()
.
Dx
()))
writeUint16
(
e
.
buf
[
2
:
4
],
uint16
(
pm
.
Bounds
()
.
Dy
()))
e
.
write
(
e
.
buf
[
:
4
])
e
.
bitsPerPixel
=
log2
(
len
(
pm
.
Palette
))
+
1
e
.
buf
[
0
]
=
0x80
|
((
uint8
(
e
.
bitsPerPixel
)
-
1
)
<<
4
)
|
(
uint8
(
e
.
bitsPerPixel
)
-
1
)
// All frames have a local color table, so a global color table
// is not needed.
e
.
buf
[
0
]
=
0x00
e
.
buf
[
1
]
=
0x00
// Background Color Index.
e
.
buf
[
2
]
=
0x00
// Pixel Aspect Ratio.
e
.
write
(
e
.
buf
[
:
3
])
// Global Color Table.
e
.
writeColorTable
(
pm
.
Palette
,
e
.
bitsPerPixel
-
1
)
// Add animation info if necessary.
if
len
(
e
.
g
.
Image
)
>
1
{
e
.
buf
[
0
]
=
0x21
// Extension Introducer.
...
...
@@ -232,7 +225,7 @@ func (e *encoder) writeImageBlock(pm *image.Paletted, delay int) {
// Local Color Table.
e
.
writeColorTable
(
pm
.
Palette
,
paddedSize
)
litWidth
:=
e
.
bitsPerPixel
litWidth
:=
paddedSize
+
1
if
litWidth
<
2
{
litWidth
=
2
}
...
...
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