// Process implements Processor. // It doesn't return 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 := imageserver_image_internal.NewAtFunc(nim) set := imageserver_image_internal.NewSetFunc(out) imageserver_image_internal.Parallel(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 = imageserver_image_internal.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 = imageserver_image_internal.NRGBAToRGBA(r, g, b, a) set(x, y, r, g, b, a) } } }) return out, nil }
// Process implements Processor. // It doesn't return error. func (prc *Processor) Process(nim image.Image, params imageserver.Params) (image.Image, error) { width := nim.Bounds().Dx() height := nim.Bounds().Dy() dst := prc.newDrawable(nim) at := imageserver_image_internal.NewAtFunc(nim) set := imageserver_image_internal.NewSetFunc(dst) imageserver_image_internal.Parallel(height, func(yStart, yEnd int) { for y := yStart; y < yEnd; y++ { for x := 0; x < width; x++ { r, g, b, a := at(x, y) r, g, b, a = imageserver_image_internal.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 = imageserver_image_internal.NRGBAToRGBA(r, g, b, a) set(x, y, r, g, b, a) } } }) return dst, nil }