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


Golang Color.RGBA方法代碼示例

本文整理匯總了Golang中image.Color.RGBA方法的典型用法代碼示例。如果您正苦於以下問題:Golang Color.RGBA方法的具體用法?Golang Color.RGBA怎麽用?Golang Color.RGBA使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在image.Color的用法示例。


在下文中一共展示了Color.RGBA方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: toColor

func toColor(color image.Color) image.Color {
	if c, ok := color.(Color); ok {
		return c
	}
	r, g, b, a := color.RGBA()
	return Color(r>>24<<24 | g>>24<<16 | b>>24<<8 | a>>24)
}
開發者ID:rapgamer,項目名稱:golang-china,代碼行數:7,代碼來源:color.go

示例2: toFloatGrayColor

func toFloatGrayColor(c image.Color) image.Color {
	if _, ok := c.(FloatGrayColor); ok {
		return c
	}
	r, g, b, _ := c.RGBA()
	y := (0.3*float(r) + 0.59*float(g) + 0.11*float(b)) / float(0xffff)
	return FloatGrayColor{y}
}
開發者ID:egonelbre,項目名稱:sivq,代碼行數:8,代碼來源:image.go

示例3: Set

func (img *surfimg) Set(x, y int, c image.Color) {
	img.Lock()
	defer img.Unlock()

	r, g, b, a := c.RGBA()

	pix := img.pixPtr(x, y)
	pix.SetUint(uint64(sdl.MapRGBA(img.Format, uint8(r), uint8(g), uint8(b), uint8(a))))
}
開發者ID:cjyar,項目名稱:Go-SDL,代碼行數:9,代碼來源:surfimg.go

示例4: PixelSimilarity

//
// Compare two pixels
// Return their similarity over the interval [0.0, 1.0]
//
func PixelSimilarity(pixel1, pixel2 image.Color) float64 {
	p1r, p1g, p1b, _ := pixel1.RGBA()
	p2r, p2g, p2b, _ := pixel2.RGBA()
	similarity := 0.0
	similarity += (PixelChannelSimilarity(p1r, p2r) / 3.0)
	similarity += (PixelChannelSimilarity(p1g, p2g) / 3.0)
	similarity += (PixelChannelSimilarity(p1b, p2b) / 3.0)
	return similarity
}
開發者ID:handcraftsman,項目名稱:instashred,代碼行數:13,代碼來源:gram.go

示例5: withinTolerance

func withinTolerance(c0, c1 image.Color, tolerance int) bool {
	r0, g0, b0, a0 := c0.RGBA()
	r1, g1, b1, a1 := c1.RGBA()
	r := delta(r0, r1)
	g := delta(g0, g1)
	b := delta(b0, b1)
	a := delta(a0, a1)
	return r <= tolerance && g <= tolerance && b <= tolerance && a <= tolerance
}
開發者ID:go-nosql,項目名稱:golang,代碼行數:9,代碼來源:decode_test.go

示例6: Mix

func Mix(x, y image.Color, theta float64) image.Color {
	rx, gx, bx, ax := x.RGBA()
	ry, gy, by, ay := y.RGBA()

	r := (1-theta)*float64(rx) + theta*float64(ry)
	g := (1-theta)*float64(gx) + theta*float64(gy)
	b := (1-theta)*float64(bx) + theta*float64(by)
	a := (1-theta)*float64(ax) + theta*float64(ay)

	return &image.RGBA64Color{uint16(r), uint16(g), uint16(b), uint16(a)}
}
開發者ID:jvlmdr,項目名稱:street-view-planets,代碼行數:11,代碼來源:interpolate.go

示例7: CountColor

func CountColor(png io.Reader) int {
	var pic image.Image
	var color image.Color

	pic, e := p.Decode(png)
	if e != nil {
		fmt.Printf("Error %v\n", e)
		return 0
	}

	cnt := 0

	colormap := make(map[string]int)
	for y := 0; y < pic.Bounds().Size().Y; y++ {
		for x := 0; x < pic.Bounds().Size().X; x++ {
			color = pic.At(x, y)
			r, g, b, _ := color.RGBA()
			key := ""
			if uint8(r) < 10 {
				key += "00" + strconv.Uitoa(uint(uint8(r)))
			} else if uint8(r) < 100 {
				key += "0" + strconv.Uitoa(uint(uint8(r)))
			} else {
				key += strconv.Uitoa(uint(uint8(r)))
			}

			if uint8(g) < 10 {
				key += "00" + strconv.Uitoa(uint(uint8(g)))
			} else if uint8(g) < 100 {
				key += "0" + strconv.Uitoa(uint(uint8(g)))
			} else {
				key += strconv.Uitoa(uint(uint8(g)))
			}

			if uint8(b) < 10 {
				key += "00" + strconv.Uitoa(uint(uint8(b)))
			} else if uint8(b) < 100 {
				key += "0" + strconv.Uitoa(uint(uint8(b)))
			} else {
				key += strconv.Uitoa(uint(uint8(b)))
			}

			if val, exist := colormap[key]; exist {
				colormap[key] = val + 1
			} else {
				colormap[key] = 1
				cnt++
			}

		}
	}

	return cnt
}
開發者ID:kokemono,項目名稱:GDD2011_DevQuiz,代碼行數:54,代碼來源:getPngColor.go

示例8: Check

func (this *HashSet) Check(color image.Color) bool {
	for i := 0; i < len(this.colors); i++ {
		buf := this.colors[i]
		r1, g1, b1, _ := buf.RGBA()
		r2, g2, b2, _ := color.RGBA()

		if r1 == r2 && g1 == g2 && b1 == b2 {
			return false
		}
	}

	return true
}
開發者ID:NorikatsuKoide,項目名稱:kemuo-samples,代碼行數:13,代碼來源:answer.go

示例9: Set

func (surface *Surface) Set(x, y int, c image.Color) {
	//TODO endianess, bpp, alpha, etc

	var bpp = int(surface.Format.BytesPerPixel)

	var pixel = uintptr(unsafe.Pointer(surface.Pixels))

	pixel += uintptr(y*int(surface.Pitch) + x*bpp)

	var p = (*image.RGBAColor)(unsafe.Pointer(pixel))

	var r, g, b, a = c.RGBA()

	p.R = uint8(r)
	p.G = uint8(g)
	p.R = uint8(b)
	p.A = uint8(255 - a)

}
開發者ID:jgastal,項目名稱:Go-SDL,代碼行數:19,代碼來源:sdldraw.go

示例10: CountColor

func CountColor(reader io.Reader) int {
	var count = map[string]int{}

	decodedPng, error := png.Decode(reader)
	if error == nil {
		var rect image.Rectangle = decodedPng.Bounds()
		for i := 0; i < rect.Size().X; i++ {
			for j := 0; j < rect.Size().Y; j++ {
				var pixel image.Color = decodedPng.At(i, j)
				var r, g, b, _ uint32 = pixel.RGBA()
				var key uint = (uint)((r << 16) + (g << 8) + (b))

				if _, ok := count[strconv.Uitoa(key)]; ok {
					count[strconv.Uitoa(key)]++
				} else {
					count[strconv.Uitoa(key)] = 1
				}
			}
		}
	}
	return len(count)
}
開發者ID:keiji,項目名稱:devQuiz_GDD11JP,代碼行數:22,代碼來源:gddquiz2011j.go

示例11: eq

func eq(c0, c1 image.Color) bool {
	r0, g0, b0, a0 := c0.RGBA()
	r1, g1, b1, a1 := c1.RGBA()
	return r0 == r1 && g0 == g1 && b0 == b1 && a0 == a1
}
開發者ID:go-nosql,項目名稱:golang,代碼行數:5,代碼來源:draw_test.go

示例12: toColor

func toColor(color image.Color) image.Color {
	if c, ok := color.(Color32); ok {
		return c
	}
	return makeColor(color.RGBA());
}
開發者ID:gyuque,項目名稱:shadergo,代碼行數:6,代碼來源:canvas.go

示例13: Set

func (m *Image) Set(x, y int, color image.Color) {
	if c, ok := color.(Color); ok {
		m.Pixel[y][x] = c
	}
	m.Pixel[y][x] = makeColor(color.RGBA())
}
開發者ID:rapgamer,項目名稱:golang-china,代碼行數:6,代碼來源:image.go

示例14: toYCbCrColor

func toYCbCrColor(c image.Color) image.Color {
	if _, ok := c.(YCbCrColor); ok {
		return c
	}
	r, g, b, _ := c.RGBA()
	y, u, v := RGBToYCbCr(uint8(r>>8), uint8(g>>8), uint8(b>>8))
	return YCbCrColor{y, u, v}
}
開發者ID:WXB506,項目名稱:golang,代碼行數:8,代碼來源:ycbcr.go


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