Пример #1
0
// Process implements Processor.
func (prc *SimpleProcessor) Process(g *gif.GIF, params imageserver.Params) (*gif.GIF, error) {
	out := new(gif.GIF)
	var err error
	out.Image, err = prc.processImages(g.Image, params)
	if err != nil {
		return nil, err
	}
	out.Delay = make([]int, len(g.Delay))
	copy(out.Delay, g.Delay)
	out.LoopCount = g.LoopCount
	if g.Disposal != nil {
		out.Disposal = make([]byte, len(g.Disposal))
		copy(out.Disposal, g.Disposal)
	}
	out.Config.ColorModel = g.Config.ColorModel
	for _, p := range out.Image {
		if p.Rect.Max.X > out.Config.Width {
			out.Config.Width = p.Rect.Max.X
		}
		if p.Rect.Max.Y > out.Config.Height {
			out.Config.Height = p.Rect.Max.Y
		}
	}
	out.BackgroundIndex = g.BackgroundIndex
	return out, nil
}