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
422abf3b
Commit
422abf3b
authored
Jun 02, 2011
by
Nigel Tao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
image: add a SubImage method.
R=r CC=golang-dev
https://golang.org/cl/4515179
parent
b873701d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
0 deletions
+100
-0
image.go
src/pkg/image/image.go
+91
-0
ycbcr.go
src/pkg/image/ycbcr/ycbcr.go
+9
-0
No files found.
src/pkg/image/image.go
View file @
422abf3b
...
...
@@ -58,6 +58,16 @@ func (p *RGBA) SetRGBA(x, y int, c RGBAColor) {
p
.
Pix
[
y
*
p
.
Stride
+
x
]
=
c
}
// SubImage returns an image representing the portion of the image p visible
// through r. The returned value shares pixels with the original image.
func
(
p
*
RGBA
)
SubImage
(
r
Rectangle
)
Image
{
return
&
RGBA
{
Pix
:
p
.
Pix
,
Stride
:
p
.
Stride
,
Rect
:
p
.
Rect
.
Intersect
(
r
),
}
}
// Opaque scans the entire image and returns whether or not it is fully opaque.
func
(
p
*
RGBA
)
Opaque
()
bool
{
if
p
.
Rect
.
Empty
()
{
...
...
@@ -117,6 +127,16 @@ func (p *RGBA64) SetRGBA64(x, y int, c RGBA64Color) {
p
.
Pix
[
y
*
p
.
Stride
+
x
]
=
c
}
// SubImage returns an image representing the portion of the image p visible
// through r. The returned value shares pixels with the original image.
func
(
p
*
RGBA64
)
SubImage
(
r
Rectangle
)
Image
{
return
&
RGBA64
{
Pix
:
p
.
Pix
,
Stride
:
p
.
Stride
,
Rect
:
p
.
Rect
.
Intersect
(
r
),
}
}
// Opaque scans the entire image and returns whether or not it is fully opaque.
func
(
p
*
RGBA64
)
Opaque
()
bool
{
if
p
.
Rect
.
Empty
()
{
...
...
@@ -176,6 +196,16 @@ func (p *NRGBA) SetNRGBA(x, y int, c NRGBAColor) {
p
.
Pix
[
y
*
p
.
Stride
+
x
]
=
c
}
// SubImage returns an image representing the portion of the image p visible
// through r. The returned value shares pixels with the original image.
func
(
p
*
NRGBA
)
SubImage
(
r
Rectangle
)
Image
{
return
&
NRGBA
{
Pix
:
p
.
Pix
,
Stride
:
p
.
Stride
,
Rect
:
p
.
Rect
.
Intersect
(
r
),
}
}
// Opaque scans the entire image and returns whether or not it is fully opaque.
func
(
p
*
NRGBA
)
Opaque
()
bool
{
if
p
.
Rect
.
Empty
()
{
...
...
@@ -235,6 +265,16 @@ func (p *NRGBA64) SetNRGBA64(x, y int, c NRGBA64Color) {
p
.
Pix
[
y
*
p
.
Stride
+
x
]
=
c
}
// SubImage returns an image representing the portion of the image p visible
// through r. The returned value shares pixels with the original image.
func
(
p
*
NRGBA64
)
SubImage
(
r
Rectangle
)
Image
{
return
&
NRGBA64
{
Pix
:
p
.
Pix
,
Stride
:
p
.
Stride
,
Rect
:
p
.
Rect
.
Intersect
(
r
),
}
}
// Opaque scans the entire image and returns whether or not it is fully opaque.
func
(
p
*
NRGBA64
)
Opaque
()
bool
{
if
p
.
Rect
.
Empty
()
{
...
...
@@ -294,6 +334,16 @@ func (p *Alpha) SetAlpha(x, y int, c AlphaColor) {
p
.
Pix
[
y
*
p
.
Stride
+
x
]
=
c
}
// SubImage returns an image representing the portion of the image p visible
// through r. The returned value shares pixels with the original image.
func
(
p
*
Alpha
)
SubImage
(
r
Rectangle
)
Image
{
return
&
Alpha
{
Pix
:
p
.
Pix
,
Stride
:
p
.
Stride
,
Rect
:
p
.
Rect
.
Intersect
(
r
),
}
}
// Opaque scans the entire image and returns whether or not it is fully opaque.
func
(
p
*
Alpha
)
Opaque
()
bool
{
if
p
.
Rect
.
Empty
()
{
...
...
@@ -353,6 +403,16 @@ func (p *Alpha16) SetAlpha16(x, y int, c Alpha16Color) {
p
.
Pix
[
y
*
p
.
Stride
+
x
]
=
c
}
// SubImage returns an image representing the portion of the image p visible
// through r. The returned value shares pixels with the original image.
func
(
p
*
Alpha16
)
SubImage
(
r
Rectangle
)
Image
{
return
&
Alpha16
{
Pix
:
p
.
Pix
,
Stride
:
p
.
Stride
,
Rect
:
p
.
Rect
.
Intersect
(
r
),
}
}
// Opaque scans the entire image and returns whether or not it is fully opaque.
func
(
p
*
Alpha16
)
Opaque
()
bool
{
if
p
.
Rect
.
Empty
()
{
...
...
@@ -412,6 +472,16 @@ func (p *Gray) SetGray(x, y int, c GrayColor) {
p
.
Pix
[
y
*
p
.
Stride
+
x
]
=
c
}
// SubImage returns an image representing the portion of the image p visible
// through r. The returned value shares pixels with the original image.
func
(
p
*
Gray
)
SubImage
(
r
Rectangle
)
Image
{
return
&
Gray
{
Pix
:
p
.
Pix
,
Stride
:
p
.
Stride
,
Rect
:
p
.
Rect
.
Intersect
(
r
),
}
}
// Opaque scans the entire image and returns whether or not it is fully opaque.
func
(
p
*
Gray
)
Opaque
()
bool
{
return
true
...
...
@@ -457,6 +527,16 @@ func (p *Gray16) SetGray16(x, y int, c Gray16Color) {
p
.
Pix
[
y
*
p
.
Stride
+
x
]
=
c
}
// SubImage returns an image representing the portion of the image p visible
// through r. The returned value shares pixels with the original image.
func
(
p
*
Gray16
)
SubImage
(
r
Rectangle
)
Image
{
return
&
Gray16
{
Pix
:
p
.
Pix
,
Stride
:
p
.
Stride
,
Rect
:
p
.
Rect
.
Intersect
(
r
),
}
}
// Opaque scans the entire image and returns whether or not it is fully opaque.
func
(
p
*
Gray16
)
Opaque
()
bool
{
return
true
...
...
@@ -544,6 +624,17 @@ func (p *Paletted) SetColorIndex(x, y int, index uint8) {
p
.
Pix
[
y
*
p
.
Stride
+
x
]
=
index
}
// SubImage returns an image representing the portion of the image p visible
// through r. The returned value shares pixels with the original image.
func
(
p
*
Paletted
)
SubImage
(
r
Rectangle
)
Image
{
return
&
Paletted
{
Pix
:
p
.
Pix
,
Stride
:
p
.
Stride
,
Rect
:
p
.
Rect
.
Intersect
(
r
),
Palette
:
p
.
Palette
,
}
}
// Opaque scans the entire image and returns whether or not it is fully opaque.
func
(
p
*
Paletted
)
Opaque
()
bool
{
for
_
,
c
:=
range
p
.
Palette
{
...
...
src/pkg/image/ycbcr/ycbcr.go
View file @
422abf3b
...
...
@@ -169,6 +169,15 @@ func (p *YCbCr) At(x, y int) image.Color {
}
}
// SubImage returns an image representing the portion of the image p visible
// through r. The returned value shares pixels with the original image.
func
(
p
*
YCbCr
)
SubImage
(
r
image
.
Rectangle
)
image
.
Image
{
q
:=
new
(
YCbCr
)
*
q
=
*
p
q
.
Rect
=
q
.
Rect
.
Intersect
(
r
)
return
q
}
func
(
p
*
YCbCr
)
Opaque
()
bool
{
return
true
}
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