Beispiel #1
0
// ConvertImageColor takes an image and a color model and returns a copy
// of the image's color with provided replacement color.
func ConvertImageColor(img image.Image, m color.Model) image.Image {
	bounds := img.Bounds()
	width, height := bounds.Max.X, bounds.Max.Y
	img2 := image.NewRGBA(image.Rect(0, 0, width, height))

	for y := 0; y < height; y++ {
		for x := 0; x < width; x++ {
			newColor := m.Convert(img.At(x, y))
			img2.Set(x, y, newColor)
		}
	}
	return img2
}
Beispiel #2
0
func cmp(t *testing.T, cm color.Model, c0, c1 color.Color) bool {
	r0, g0, b0, a0 := cm.Convert(c0).RGBA()
	r1, g1, b1, a1 := cm.Convert(c1).RGBA()
	return r0 == r1 && g0 == g1 && b0 == b1 && a0 == a1
}