本文整理匯總了Golang中image.NRGBA64.NRGBA64At方法的典型用法代碼示例。如果您正苦於以下問題:Golang NRGBA64.NRGBA64At方法的具體用法?Golang NRGBA64.NRGBA64At怎麽用?Golang NRGBA64.NRGBA64At使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類image.NRGBA64
的用法示例。
在下文中一共展示了NRGBA64.NRGBA64At方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: AverageNRGBA64
func AverageNRGBA64(rect image.Rectangle, img *image.NRGBA64) color.NRGBA64 {
// Only use the area of the rectangle that overlaps with the image bounds.
rect = rect.Intersect(img.Bounds())
// Determine whether or not there's any area over which to determine an
// average.
d := uint64(rect.Dx() * rect.Dy())
if d == 0 {
return color.NRGBA64{}
}
var r, g, b, a uint64
AllPointsRP(
func(pt image.Point) {
c := img.NRGBA64At(pt.X, pt.Y)
r += uint64(c.R)
g += uint64(c.G)
b += uint64(c.B)
a += uint64(c.A)
},
)(rect)
return color.NRGBA64{
R: uint16(r / d),
G: uint16(g / d),
B: uint16(b / d),
A: uint16(a / d),
}
}
示例2: NRGBA64ToChannels
// Channels decomposes a given NRGBA64 into red, green, blue, and alpha Channels.
func NRGBA64ToChannels(img *image.NRGBA64) (r, g, b, a Channel) {
r = channel{
bounds: img.Bounds,
gray16At: func(x, y int) color.Gray16 {
return color.Gray16{
Y: img.NRGBA64At(x, y).R,
}
},
}
g = channel{
bounds: img.Bounds,
gray16At: func(x, y int) color.Gray16 {
return color.Gray16{
Y: img.NRGBA64At(x, y).G,
}
},
}
b = channel{
bounds: img.Bounds,
gray16At: func(x, y int) color.Gray16 {
return color.Gray16{
Y: img.NRGBA64At(x, y).B,
}
},
}
a = channel{
bounds: img.Bounds,
gray16At: func(x, y int) color.Gray16 {
return color.Gray16{
Y: img.NRGBA64At(x, y).A,
}
},
}
return
}