Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
7df45566
Commit
7df45566
authored
Nov 04, 2009
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gofmt-ify image
R=rsc
http://go/go-review/1017044
parent
ca2a69ea
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
16 deletions
+16
-16
src/pkg/image/png/reader_test.go
src/pkg/image/png/reader_test.go
+4
-4
src/pkg/image/png/writer.go
src/pkg/image/png/writer.go
+12
-12
No files found.
src/pkg/image/png/reader_test.go
View file @
7df45566
...
...
@@ -15,7 +15,7 @@ import (
// The go PNG library currently supports only a subset of the full PNG specification.
// In particular, bit depths other than 8 are not supported, and neither are grayscale images.
var
filenames
=
[]
string
{
var
filenames
=
[]
string
{
//"basn0g01", // bit depth is not 8
//"basn0g02", // bit depth is not 8
//"basn0g04", // bit depth is not 8
...
...
@@ -114,7 +114,7 @@ func TestReader(t *testing.T) {
image
,
err
:=
readPng
(
"testdata/pngsuite/"
+
fn
+
".png"
);
if
err
!=
nil
{
t
.
Error
(
fn
,
err
);
continue
continue
;
}
piper
,
pipew
:=
io
.
Pipe
();
pb
:=
bufio
.
NewReader
(
piper
);
...
...
@@ -125,13 +125,13 @@ func TestReader(t *testing.T) {
sf
,
err
:=
os
.
Open
(
"testdata/pngsuite/"
+
fn
+
".sng"
,
os
.
O_RDONLY
,
0444
);
if
err
!=
nil
{
t
.
Error
(
fn
,
err
);
continue
continue
;
}
defer
sf
.
Close
();
sb
:=
bufio
.
NewReader
(
sf
);
if
err
!=
nil
{
t
.
Error
(
fn
,
err
);
continue
continue
;
}
// Compare the two, in SNG format, line by line.
...
...
src/pkg/image/png/writer.go
View file @
7df45566
...
...
@@ -137,18 +137,18 @@ func filter(cr [][]byte, pr []byte, bpp int) int {
// This is the same heuristic that libpng uses, although the filters are attempted in order of
// estimated most likely to be minimal (ftUp, ftPaeth, ftNone, ftSub, ftAverage), rather than
// in their enumeration order (ftNone, ftSub, ftUp, ftAverage, ftPaeth).
cdat0
:=
cr
[
0
][
1
:
len
(
cr
[
0
])];
cdat1
:=
cr
[
1
][
1
:
len
(
cr
[
1
])];
cdat2
:=
cr
[
2
][
1
:
len
(
cr
[
2
])];
cdat3
:=
cr
[
3
][
1
:
len
(
cr
[
3
])];
cdat4
:=
cr
[
4
][
1
:
len
(
cr
[
4
])];
pdat
:=
pr
[
1
:
len
(
pr
)];
cdat0
:=
cr
[
0
][
1
:
len
(
cr
[
0
])];
cdat1
:=
cr
[
1
][
1
:
len
(
cr
[
1
])];
cdat2
:=
cr
[
2
][
1
:
len
(
cr
[
2
])];
cdat3
:=
cr
[
3
][
1
:
len
(
cr
[
3
])];
cdat4
:=
cr
[
4
][
1
:
len
(
cr
[
4
])];
pdat
:=
pr
[
1
:
len
(
pr
)];
n
:=
len
(
cdat0
);
// The up filter.
sum
:=
0
;
for
i
:=
0
;
i
<
n
;
i
++
{
cdat2
[
i
]
=
cdat0
[
i
]
-
pdat
[
i
];
cdat2
[
i
]
=
cdat0
[
i
]
-
pdat
[
i
];
sum
+=
abs8
(
cdat2
[
i
]);
}
best
:=
sum
;
...
...
@@ -192,7 +192,7 @@ func filter(cr [][]byte, pr []byte, bpp int) int {
sum
+=
abs8
(
cdat1
[
i
]);
}
for
i
:=
bpp
;
i
<
n
;
i
++
{
cdat1
[
i
]
=
cdat0
[
i
]
-
cdat0
[
i
-
bpp
];
cdat1
[
i
]
=
cdat0
[
i
]
-
cdat0
[
i
-
bpp
];
sum
+=
abs8
(
cdat1
[
i
]);
if
sum
>=
best
{
break
;
...
...
@@ -206,11 +206,11 @@ func filter(cr [][]byte, pr []byte, bpp int) int {
// The average filter.
sum
=
0
;
for
i
:=
0
;
i
<
bpp
;
i
++
{
cdat3
[
i
]
=
cdat0
[
i
]
-
pdat
[
i
]
/
2
;
cdat3
[
i
]
=
cdat0
[
i
]
-
pdat
[
i
]
/
2
;
sum
+=
abs8
(
cdat3
[
i
]);
}
for
i
:=
bpp
;
i
<
n
;
i
++
{
cdat3
[
i
]
=
cdat0
[
i
]
-
uint8
((
int
(
cdat0
[
i
-
bpp
])
+
int
(
pdat
[
i
]))
/
2
);
cdat3
[
i
]
=
cdat0
[
i
]
-
uint8
((
int
(
cdat0
[
i
-
bpp
])
+
int
(
pdat
[
i
]))
/
2
);
sum
+=
abs8
(
cdat3
[
i
]);
if
sum
>=
best
{
break
;
...
...
@@ -249,10 +249,10 @@ func writeImage(w io.Writer, m image.Image, ct uint8) os.Error {
// The +1 is for the per-row filter type, which is at cr[*][0].
var
cr
[
nFilter
][]
uint8
;
for
i
:=
0
;
i
<
len
(
cr
);
i
++
{
cr
[
i
]
=
make
([]
uint8
,
1
+
bpp
*
m
.
Width
());
cr
[
i
]
=
make
([]
uint8
,
1
+
bpp
*
m
.
Width
());
cr
[
i
][
0
]
=
uint8
(
i
);
}
pr
:=
make
([]
uint8
,
1
+
bpp
*
m
.
Width
());
pr
:=
make
([]
uint8
,
1
+
bpp
*
m
.
Width
());
for
y
:=
0
;
y
<
m
.
Height
();
y
++
{
// Convert from colors to bytes.
...
...
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