Example #1
0
func getPixelBytes(img image.NRGBA, pixel LsbPixel) byte {
	rgba := img.NRGBAAt(pixel.GetX(), pixel.GetY())
	switch pixel.GetLayer() {
	case "r":
		return rgba.R
	case "g":
		return rgba.G
	case "b":
		return rgba.B
	case "a":
		return rgba.A
	}
	return 0
}
Example #2
0
func setPixelBytes(img image.NRGBA, pixel LsbPixel, byt byte) {
	rgba := img.NRGBAAt(pixel.GetX(), pixel.GetY())
	switch pixel.GetLayer() {
	case "r":
		rgba.R = byt
	case "g":
		rgba.G = byt
	case "b":
		rgba.B = byt
	case "a":
		rgba.A = byt
	}
	img.Set(pixel.GetX(), pixel.GetY(), rgba)
}
Example #3
0
// Takes an average of the biome colors of the surrounding area
func calculateBiome(bs *blocksSnapshot, x, z int, img *image.NRGBA) (byte, byte, byte) {
	count := 0
	var r, g, b int
	for xx := -2; xx <= 2; xx++ {
		for zz := -2; zz <= 2; zz++ {
			biome := bs.biome(x+xx, z+zz)
			ix := biome.ColorIndex & 0xFF
			iy := biome.ColorIndex >> 8
			col := img.NRGBAAt(ix, iy)
			r += int(col.R)
			g += int(col.G)
			b += int(col.B)
			count++
		}
	}
	return byte(r / count), byte(g / count), byte(b / count)
}