當前位置: 首頁>>代碼示例>>Golang>>正文


Golang NRGBA64.NRGBA64At方法代碼示例

本文整理匯總了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),
	}
}
開發者ID:buth,項目名稱:imageutil,代碼行數:30,代碼來源:average.go

示例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
}
開發者ID:buth,項目名稱:imageutil,代碼行數:40,代碼來源:channel.go


注:本文中的image.NRGBA64.NRGBA64At方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。