예제 #1
0
func newSetFuncCMYK(p *image.CMYK) SetFunc {
	return func(x, y int, r, g, b, a uint32) {
		rr := uint32(r >> 8)
		gg := uint32(g >> 8)
		bb := uint32(b >> 8)
		w := rr
		if w < gg {
			w = gg
		}
		if w < bb {
			w = bb
		}
		var c8, m8, y8, k8 uint8
		if w == 0 {
			k8 = 0xff
		} else {
			c8 = uint8((w - rr) * 0xff / w)
			m8 = uint8((w - gg) * 0xff / w)
			y8 = uint8((w - bb) * 0xff / w)
			k8 = uint8(0xff - w)
		}
		i := p.PixOffset(x, y)
		p.Pix[i+0] = c8
		p.Pix[i+1] = m8
		p.Pix[i+2] = y8
		p.Pix[i+3] = k8
	}
}
예제 #2
0
func newAtFuncCMYK(p *image.CMYK) AtFunc {
	return func(x, y int) (r, g, b, a uint32) {
		i := p.PixOffset(x, y)
		w := uint32(0xffff - uint32(p.Pix[i+3])*0x101)
		r = uint32(0xffff-uint32(p.Pix[i+0])*0x101) * w / 0xffff
		g = uint32(0xffff-uint32(p.Pix[i+1])*0x101) * w / 0xffff
		b = uint32(0xffff-uint32(p.Pix[i+2])*0x101) * w / 0xffff
		a = 0xffff
		return
	}
}