예제 #1
0
func (c Color) ColorModel() image.ColorModel { return image.ColorModelFunc(toColor) }
예제 #2
0
파일: canvas.go 프로젝트: gyuque/shadergo
		}
	}
}

func TestFuncs() {
	var list [3]int;
	var ilist [3]int;	

	list[0], list[1], list[2],
	ilist[0], ilist[1], ilist[2] = sort3(1,2,1); 
	fmt.Printf("%d %d %d  %d %d %d\n", list[0], list[1], list[2], ilist[0], ilist[1], ilist[2]);
}

func (m *CanvasImage) ColorModel() image.ColorModel {
	return ColorModel
}

func makeColor(r, g, b, a uint32) Color32 {
	return Color32(a>>24<<24 | r>>24<<16 | g>>24<<8 | b>>24)
}

func toColor(color image.Color) image.Color {
	if c, ok := color.(Color32); ok {
		return c
	}
	return makeColor(color.RGBA());
}

var ColorModel = image.ColorModelFunc(toColor)

예제 #3
0
파일: ycbcr.go 프로젝트: WXB506/golang
func (c YCbCrColor) RGBA() (uint32, uint32, uint32, uint32) {
	r, g, b := YCbCrToRGB(c.Y, c.Cb, c.Cr)
	return uint32(r) * 0x101, uint32(g) * 0x101, uint32(b) * 0x101, 0xffff
}

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}
}

// YCbCrColorModel is the color model for YCbCrColor.
var YCbCrColorModel image.ColorModel = image.ColorModelFunc(toYCbCrColor)

// SubsampleRatio is the chroma subsample ratio used in a YCbCr image.
type SubsampleRatio int

const (
	SubsampleRatio444 SubsampleRatio = iota
	SubsampleRatio422
	SubsampleRatio420
)

// YCbCr is an in-memory image of YCbCr colors. There is one Y sample per pixel,
// but each Cb and Cr sample can span one or more pixels.
// YStride is the Y slice index delta between vertically adjacent pixels.
// CStride is the Cb and Cr slice index delta between vertically adjacent pixels
// that map to separate chroma samples.
예제 #4
0
파일: image.go 프로젝트: egonelbre/sivq
	} else {
		y = (uint32)(c.Y * 0xffff)
	}
	return y, y, y, 0xffff
}

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}
}

var FloatGrayColorModel image.ColorModel = image.ColorModelFunc(toFloatGrayColor)

type FloatGray struct {
	Pix    []FloatGrayColor
	Stride int
	Rect   image.Rectangle
}

func (p *FloatGray) ColorModel() image.ColorModel { return FloatGrayColorModel }

func (p *FloatGray) Bounds() image.Rectangle { return p.Rect }

func (p *FloatGray) At(x, y int) image.Color {
	if !p.Rect.Contains(image.Point{x, y}) {
		return FloatGrayColor{}
	}