Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小雨青年
freetype
提交
3657abe8
F
freetype
项目概览
小雨青年
/
freetype
通知
14
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
freetype
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
3657abe8
编写于
8月 10, 2010
作者:
N
Nigel Tao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
freetype: update for image representation change (1849041).
R=r, adg CC=golang-dev
http://codereview.appspot.com/1850041
上级
2e8bf4f4
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
38 addition
and
31 deletion
+38
-31
example/freetype/main.go
example/freetype/main.go
+1
-1
example/gamma/main.go
example/gamma/main.go
+6
-3
example/raster/main.go
example/raster/main.go
+1
-1
example/round/main.go
example/round/main.go
+4
-3
freetype/raster/paint.go
freetype/raster/paint.go
+26
-23
未找到文件。
example/freetype/main.go
浏览文件 @
3657abe8
...
...
@@ -88,7 +88,7 @@ func main() {
ruler
=
image
.
RGBAColor
{
0x22
,
0x22
,
0x22
,
0xff
}
}
rgba
:=
image
.
NewRGBA
(
640
,
480
)
draw
.
Draw
(
rgba
,
draw
.
Rect
(
0
,
0
,
rgba
.
Width
(),
rgba
.
Height
()
),
bg
,
draw
.
ZP
)
draw
.
Draw
(
rgba
,
draw
.
Rect
(
0
,
0
,
640
,
480
),
bg
,
draw
.
ZP
)
c
:=
freetype
.
NewContext
()
c
.
SetDPI
(
*
dpi
)
c
.
SetFont
(
font
)
...
...
example/gamma/main.go
浏览文件 @
3657abe8
...
...
@@ -22,9 +22,12 @@ func p(x, y int) raster.Point {
}
func
clear
(
m
*
image
.
Alpha
)
{
for
y
:=
0
;
y
<
m
.
Height
();
y
++
{
for
x
:=
0
;
x
<
m
.
Width
();
x
++
{
m
.
Pixel
[
y
][
x
]
=
image
.
AlphaColor
{
0
}
b
:=
m
.
Bounds
()
for
y
:=
b
.
Min
.
Y
;
y
<
b
.
Max
.
Y
;
y
++
{
base
:=
y
*
m
.
Stride
p
:=
m
.
Pix
[
base
+
b
.
Min
.
X
:
base
+
b
.
Max
.
X
]
for
i
,
_
:=
range
p
{
p
[
i
]
=
image
.
AlphaColor
{
0
}
}
}
}
...
...
example/raster/main.go
浏览文件 @
3657abe8
...
...
@@ -113,7 +113,7 @@ func showNodes(m *image.RGBA, ns []node) {
for
_
,
n
:=
range
ns
{
p
:=
p
(
n
)
x
,
y
:=
int
(
p
.
X
)
/
256
,
int
(
p
.
Y
)
/
256
if
x
<
0
||
x
>=
m
.
Width
()
||
y
<
0
||
y
>=
m
.
Height
(
)
{
if
!
m
.
Bounds
()
.
Contains
(
image
.
Point
{
x
,
y
}
)
{
continue
}
var
c
image
.
Color
...
...
example/round/main.go
浏览文件 @
3657abe8
...
...
@@ -31,9 +31,10 @@ func main() {
t
:=
raster
.
Fix32
(
r
*
math
.
Tan
(
math
.
Pi
/
8
))
m
:=
image
.
NewRGBA
(
800
,
600
)
for
y
:=
0
;
y
<
m
.
Height
();
y
++
{
for
x
:=
0
;
x
<
m
.
Width
();
x
++
{
m
.
Pixel
[
y
][
x
]
=
image
.
RGBAColor
{
63
,
63
,
63
,
255
}
for
y
:=
0
;
y
<
600
;
y
++
{
p
:=
m
.
Pix
[
y
*
m
.
Stride
:
y
*
m
.
Stride
+
800
]
for
i
:=
range
p
{
p
[
i
]
=
image
.
RGBAColor
{
63
,
63
,
63
,
255
}
}
}
mp
:=
raster
.
NewRGBAPainter
(
m
)
...
...
freetype/raster/paint.go
浏览文件 @
3657abe8
...
...
@@ -43,31 +43,33 @@ type AlphaPainter struct {
// Paint satisfies the Painter interface by painting ss onto an image.Alpha.
func
(
r
*
AlphaPainter
)
Paint
(
ss
[]
Span
,
done
bool
)
{
b
:=
r
.
Image
.
Bounds
()
for
_
,
s
:=
range
ss
{
if
s
.
Y
<
0
{
if
s
.
Y
<
b
.
Min
.
Y
{
continue
}
if
s
.
Y
>=
len
(
r
.
Image
.
Pixel
)
{
if
s
.
Y
>=
b
.
Max
.
Y
{
return
}
p
:=
r
.
Image
.
Pixel
[
s
.
Y
]
if
s
.
X0
<
0
{
s
.
X0
=
0
if
s
.
X0
<
b
.
Min
.
X
{
s
.
X0
=
b
.
Min
.
X
}
if
s
.
X1
>
len
(
p
)
{
s
.
X1
=
len
(
p
)
if
s
.
X1
>
b
.
Max
.
X
{
s
.
X1
=
b
.
Max
.
X
}
base
:=
s
.
Y
*
r
.
Image
.
Stride
p
:=
r
.
Image
.
Pix
[
base
+
s
.
X0
:
base
+
s
.
X1
]
if
r
.
Op
==
draw
.
Over
{
a
:=
int
(
s
.
A
>>
24
)
for
x
:=
s
.
X0
;
x
<
s
.
X1
;
x
++
{
ax
:=
int
(
p
[
x
]
.
A
)
for
i
,
c
:=
range
p
{
ax
:=
int
(
c
.
A
)
ax
=
(
ax
*
255
+
(
255
-
ax
)
*
a
)
/
255
p
[
x
]
=
image
.
AlphaColor
{
uint8
(
ax
)}
p
[
i
]
=
image
.
AlphaColor
{
uint8
(
ax
)}
}
}
else
{
color
:=
image
.
AlphaColor
{
uint8
(
s
.
A
>>
24
)}
for
x
:=
s
.
X0
;
x
<
s
.
X1
;
x
++
{
p
[
x
]
=
color
for
i
:=
range
p
{
p
[
i
]
=
color
}
}
}
...
...
@@ -89,28 +91,29 @@ type RGBAPainter struct {
// Paint satisfies the Painter interface by painting ss onto an image.RGBA.
func
(
r
*
RGBAPainter
)
Paint
(
ss
[]
Span
,
done
bool
)
{
b
:=
r
.
Image
.
Bounds
()
for
_
,
s
:=
range
ss
{
if
s
.
Y
<
0
{
if
s
.
Y
<
b
.
Min
.
Y
{
continue
}
if
s
.
Y
>=
len
(
r
.
Image
.
Pixel
)
{
if
s
.
Y
>=
b
.
Max
.
Y
{
return
}
p
:=
r
.
Image
.
Pixel
[
s
.
Y
]
if
s
.
X0
<
0
{
s
.
X0
=
0
if
s
.
X0
<
b
.
Min
.
X
{
s
.
X0
=
b
.
Min
.
X
}
if
s
.
X1
>
len
(
p
)
{
s
.
X1
=
len
(
p
)
if
s
.
X1
>
b
.
Max
.
X
{
s
.
X1
=
b
.
Max
.
X
}
for
x
:=
s
.
X0
;
x
<
s
.
X1
;
x
++
{
base
:=
s
.
Y
*
r
.
Image
.
Stride
p
:=
r
.
Image
.
Pix
[
base
+
s
.
X0
:
base
+
s
.
X1
]
for
i
,
rgba
:=
range
p
{
// This code is duplicated from drawGlyphOver in $GOROOT/src/pkg/exp/draw/draw.go.
// TODO(nigeltao): Factor out common code into a utility function, once the compiler
// can inline such function calls.
ma
:=
s
.
A
>>
16
const
M
=
1
<<
16
-
1
if
r
.
Op
==
draw
.
Over
{
rgba
:=
p
[
x
]
dr
:=
uint32
(
rgba
.
R
)
dg
:=
uint32
(
rgba
.
G
)
db
:=
uint32
(
rgba
.
B
)
...
...
@@ -121,13 +124,13 @@ func (r *RGBAPainter) Paint(ss []Span, done bool) {
dg
=
(
dg
*
a
+
r
.
cg
*
ma
)
/
M
db
=
(
db
*
a
+
r
.
cb
*
ma
)
/
M
da
=
(
da
*
a
+
r
.
ca
*
ma
)
/
M
p
[
x
]
=
image
.
RGBAColor
{
uint8
(
dr
>>
8
),
uint8
(
dg
>>
8
),
uint8
(
db
>>
8
),
uint8
(
da
>>
8
)}
p
[
i
]
=
image
.
RGBAColor
{
uint8
(
dr
>>
8
),
uint8
(
dg
>>
8
),
uint8
(
db
>>
8
),
uint8
(
da
>>
8
)}
}
else
{
dr
:=
r
.
cr
*
ma
/
M
dg
:=
r
.
cg
*
ma
/
M
db
:=
r
.
cb
*
ma
/
M
da
:=
r
.
ca
*
ma
/
M
p
[
x
]
=
image
.
RGBAColor
{
uint8
(
dr
>>
8
),
uint8
(
dg
>>
8
),
uint8
(
db
>>
8
),
uint8
(
da
>>
8
)}
p
[
i
]
=
image
.
RGBAColor
{
uint8
(
dr
>>
8
),
uint8
(
dg
>>
8
),
uint8
(
db
>>
8
),
uint8
(
da
>>
8
)}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录