// Copy copies src to dst. func Copy(dst draw.Image, src image.Image) { bd := src.Bounds().Intersect(dst.Bounds()) at := imageutil.NewAtFunc(src) set := imageutil.NewSetFunc(dst) imageutil.Parallel1D(bd, func(bd image.Rectangle) { for y := bd.Min.Y; y < bd.Max.Y; y++ { for x := bd.Min.X; x < bd.Max.X; x++ { r, g, b, a := at(x, y) set(x, y, r, g, b, a) } } }) }
// Process implements imageserver/image.Processor. // // It doesn't return an error. func (prc *Processor) Process(nim image.Image, params imageserver.Params) (image.Image, error) { out := prc.newDrawable(nim) bd := nim.Bounds().Intersect(out.Bounds()) at := imageutil.NewAtFunc(nim) set := imageutil.NewSetFunc(out) imageutil.Parallel1D(bd, func(bd image.Rectangle) { for y := bd.Min.Y; y < bd.Max.Y; y++ { for x := bd.Min.X; x < bd.Max.X; x++ { r, g, b, a := at(x, y) r, g, b, a = imageutil.RGBAToNRGBA(r, g, b, a) r = uint32(prc.vals[uint16(r)]) g = uint32(prc.vals[uint16(g)]) b = uint32(prc.vals[uint16(b)]) r, g, b, a = imageutil.NRGBAToRGBA(r, g, b, a) set(x, y, r, g, b, a) } } }) return out, nil }