github.com/cellofellow/gopkg@v0.0.0-20140722061823-eec0544a62ad/image/draw/ycbcr.go (about) 1 // Copyright 2014 <chaishushan{AT}gmail.com>. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package draw 6 7 import ( 8 "image" 9 "image/color" 10 ) 11 12 type yCbCr struct { 13 *image.YCbCr 14 } 15 16 func (p *yCbCr) Set(x, y int, c color.Color) { 17 if !(image.Point{x, y}.In(p.Rect)) { 18 return 19 } 20 yi := p.YOffset(x, y) 21 ci := p.COffset(x, y) 22 c1 := color.YCbCrModel.Convert(c).(color.YCbCr) 23 p.Y[yi] = c1.Y 24 p.Cb[ci] = c1.Cb 25 p.Cr[ci] = c1.Cr 26 } 27 28 func (p *yCbCr) SetYCbCr(x, y int, c color.YCbCr) { 29 if !(image.Point{x, y}.In(p.Rect)) { 30 return 31 } 32 yi := p.YOffset(x, y) 33 ci := p.COffset(x, y) 34 p.Y[yi] = c.Y 35 p.Cb[ci] = c.Cb 36 p.Cr[ci] = c.Cr 37 }