From 223d32722dbf85868eba90f92fcfcb82572cacca Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Sat, 2 Sep 2023 17:19:51 -0600 Subject: [PATCH] Transparency = Black --- cmd/wallart-server/main.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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) }