Add support snapshot for raw image format

This commit is contained in:
Alex X
2025-01-07 20:08:29 +03:00
parent 33e0ccdd10
commit e4b8d1807d
4 changed files with 43 additions and 2 deletions
+24
View File
@@ -123,3 +123,27 @@ func NewImage(fmtp string) func(frame []byte) image.Image {
return nil
}
// HasSameColor checks if all pixels has same color
func HasSameColor(img image.Image) bool {
var pix []byte
switch img := img.(type) {
case *image.Gray:
pix = img.Pix
case *image.YCbCr:
pix = img.Y
}
if len(pix) == 0 {
return false
}
i0 := pix[0]
for _, i := range pix {
if i != i0 {
return false
}
}
return true
}