Transparency = Black
This commit is contained in:
parent
497d33e78a
commit
223d32722d
|
@ -112,19 +112,22 @@ func handleUpload(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
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] {
|
switch inputGif.Disposal[i] {
|
||||||
case gif.DisposalNone:
|
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)
|
draw.Over.Draw(dst, img.Rect, img, img.Rect.Min)
|
||||||
undisposedImg = dst
|
undisposedImg = dst
|
||||||
case gif.DisposalBackground:
|
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)
|
draw.Over.Draw(dst, img.Rect, img, img.Rect.Min)
|
||||||
case gif.DisposalPrevious:
|
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)
|
draw.Over.Draw(dst, img.Rect, img, img.Rect.Min)
|
||||||
default:
|
default:
|
||||||
draw.Src.Draw(dst, img.Rect, image.Black, image.Point{})
|
|
||||||
draw.Over.Draw(dst, img.Rect, img, img.Rect.Min)
|
draw.Over.Draw(dst, img.Rect, img, img.Rect.Min)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue