diff --git a/cmd/wallart-server/main.go b/cmd/wallart-server/main.go index 35b01e9..5e6364f 100644 --- a/cmd/wallart-server/main.go +++ b/cmd/wallart-server/main.go @@ -112,19 +112,22 @@ func handleUpload(w http.ResponseWriter, r *http.Request) { return } + // Implement GIF disposal modes + // Normally you woud want to use draw.Src instead of draw.Over for the first of each of these. + // But in this particular application, we want transparency to become black. + draw.Src.Draw(dst, imgRect, image.Black, image.Point{}) switch inputGif.Disposal[i] { case gif.DisposalNone: - draw.Src.Draw(dst, previousImg.Rect, previousImg, image.Point{}) + draw.Over.Draw(dst, previousImg.Rect, previousImg, image.Point{}) draw.Over.Draw(dst, img.Rect, img, img.Rect.Min) undisposedImg = dst case gif.DisposalBackground: - draw.Src.Draw(dst, backgroundImg.Rect, backgroundImg, image.Point{}) + draw.Over.Draw(dst, backgroundImg.Rect, backgroundImg, image.Point{}) draw.Over.Draw(dst, img.Rect, img, img.Rect.Min) case gif.DisposalPrevious: - draw.Src.Draw(dst, undisposedImg.Rect, undisposedImg, image.Point{}) + draw.Over.Draw(dst, undisposedImg.Rect, undisposedImg, image.Point{}) draw.Over.Draw(dst, img.Rect, img, img.Rect.Min) default: - draw.Src.Draw(dst, img.Rect, image.Black, image.Point{}) draw.Over.Draw(dst, img.Rect, img, img.Rect.Min) }