本文整理匯總了Golang中image.RGBA.RGBAAt方法的典型用法代碼示例。如果您正苦於以下問題:Golang RGBA.RGBAAt方法的具體用法?Golang RGBA.RGBAAt怎麽用?Golang RGBA.RGBAAt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類image.RGBA
的用法示例。
在下文中一共展示了RGBA.RGBAAt方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: dist2
func dist2(a, b *image.RGBA) float32 {
a0 := a.Bounds().Min
b0 := b.Bounds().Min
s := a.Bounds().Size()
if s.Eq(b.Bounds().Size()) == false {
return math.MaxFloat32
}
d := float32(0.)
for j := 0; j < s.Y; j++ {
for i := 0; i < s.X; i++ {
ca := a.RGBAAt(a0.X+i, a0.Y+j)
cb := b.RGBAAt(b0.X+i, b0.Y+j)
dr := (float32(ca.R) - float32(cb.R)) / 255.
dg := (float32(ca.G) - float32(cb.G)) / 255.
db := (float32(ca.B) - float32(cb.B)) / 255.
da := (float32(ca.A) - float32(cb.A)) / 255.
d += dr*dr + db*db + dg*dg + da*da
}
}
return d
}
示例2: ImageEnhanceRGB
func ImageEnhanceRGB(img *image.RGBA, enhanceDegress float32, enhanceOffset float32, enhanceChannel [3]bool) *image.RGBA {
rgbFunc := func(xpos, ypos int) (r0, g0, b0, a0 uint8) {
rgba := img.RGBAAt(xpos, ypos)
return rgba.R, rgba.G, rgba.B, rgba.A
}
imgEnhanced := imenhance(enhanceDegress, enhanceOffset, enhanceChannel, false, img.Rect, rgbFunc)
return imgEnhanced
}
示例3: ImageEnhanceRGBWithFunc
func ImageEnhanceRGBWithFunc(img *image.RGBA, enhanceFunc func(r, g, b float32) (float32, float32, float32)) *image.RGBA {
rgbFunc := func(xpos, ypos int) (r0, g0, b0, a0 uint8) {
rgba := img.RGBAAt(xpos, ypos)
r, g, b := enhanceFunc(float32(rgba.R), float32(rgba.G), float32(rgba.B))
return oneColorCorrect(r), oneColorCorrect(g), oneColorCorrect(b), rgba.A
}
imgEnhanced := imenhance(1, 0, [3]bool{true, true, true}, true, img.Rect, rgbFunc)
return imgEnhanced
}
示例4: paint
func paint(mgr *gpio.Gpio, interval interval, img *image.RGBA) {
yStride := img.Rect.Dy() / 2
for y := img.Rect.Min.Y; y < img.Rect.Min.Y+yStride; y++ {
for i := 1; i < colors; i++ {
thresh := uint8(i * 256 / colors)
for x := img.Rect.Min.X; x < img.Rect.Max.X; x++ {
var data uint32
color := img.RGBAAt(x, y)
if color.R >= thresh {
data |= 1 << pinR1
}
if color.G >= thresh {
data |= 1 << pinG1
}
if color.B >= thresh {
data |= 1 << pinB1
}
color = img.RGBAAt(x, y+yStride)
if color.R >= thresh {
data |= 1 << pinR2
}
if color.G >= thresh {
data |= 1 << pinG2
}
if color.B >= thresh {
data |= 1 << pinB2
}
mgr.Set(data, 1<<pinR1|1<<pinG1|1<<pinB1|1<<pinR2|1<<pinG2|1<<pinB2)
mgr.Strobe(pinClk)
}
// all set up to strobe; wait for end of interval
interval.wait()
if i == 1 {
var addr uint32
if y&0x8 != 0 {
addr |= 1 << pinA3
}
if y&0x4 != 0 {
addr |= 1 << pinA2
}
if y&0x2 != 0 {
addr |= 1 << pinA1
}
if y&0x1 != 0 {
addr |= 1 << pinA0
}
mgr.Set(1<<pinOE, 1<<pinOE)
mgr.Set(addr, 1<<pinA3|1<<pinA2|1<<pinA1|1<<pinA0)
}
mgr.Strobe(pinLat)
if i == 1 {
mgr.Set(0, 1<<pinOE)
}
}
}
}
示例5: NewPictureFromRGBA
func NewPictureFromRGBA(img *image.RGBA) *Picture {
p := NewPicture(img.Bounds())
p.Each(func(x, y int) {
c := img.RGBAAt(x, y)
l := p.Luma(c)
p.Set(x, y, l)
})
return p
}
示例6: ImageFilterRGB
func ImageFilterRGB(img *image.RGBA, filter [][]float32, lowQuality bool) *image.RGBA {
if lowQuality {
imgAva := ImageEnhanceRGB(img, filter[0][0], 0, [3]bool{true, true, true})
return imfilter(filter, img.Rect, func(xpos, ypos int) (r0, g0, b0, a0 uint8) {
rgba := imgAva.RGBAAt(xpos, ypos)
return rgba.R, rgba.G, rgba.B, rgba.A
}, func(filterValue, colorValue float32) float32 {
return colorValue
})
}
return imfilter(filter, img.Rect, func(xpos, ypos int) (r0, g0, b0, a0 uint8) {
rgba := img.RGBAAt(xpos, ypos)
return rgba.R, rgba.G, rgba.B, rgba.A
}, func(filterValue, colorValue float32) float32 {
return filterValue * colorValue
})
}
示例7: sendImage
func sendImage(m *image.RGBA) {
c, err := net.Dial("udp", "151.217.8.152:6073")
if err != nil {
log.Fatal(err)
}
uc := c.(*net.UDPConn)
uc.SetWriteBuffer(width*height*3 + 1)
var buf bytes.Buffer
buf.WriteByte(0)
for y := 0; y < height; y++ {
for x := 0; x < width; x++ {
c := m.RGBAAt(x, y)
buf.WriteByte(c.R)
buf.WriteByte(c.G)
buf.WriteByte(c.B)
}
}
c.Write(buf.Bytes())
}