opaque.go 742 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // License: GPLv3 Copyright: 2023, Kovid Goyal, <kovid at kovidgoyal.net>
  2. package images
  3. import (
  4. "fmt"
  5. "image"
  6. )
  7. var _ = fmt.Print
  8. func IsOpaque(img image.Image) bool {
  9. switch i := img.(type) {
  10. case *image.RGBA:
  11. return i.Opaque()
  12. case *image.RGBA64:
  13. return i.Opaque()
  14. case *image.NRGBA:
  15. return i.Opaque()
  16. case *image.NRGBA64:
  17. return i.Opaque()
  18. case *image.Alpha:
  19. return i.Opaque()
  20. case *image.Alpha16:
  21. return i.Opaque()
  22. case *image.Gray:
  23. return i.Opaque()
  24. case *image.Gray16:
  25. return i.Opaque()
  26. case *image.CMYK:
  27. return i.Opaque()
  28. case *image.Paletted:
  29. return i.Opaque()
  30. case *image.Uniform:
  31. return i.Opaque()
  32. case *image.YCbCr:
  33. return i.Opaque()
  34. case *NRGB:
  35. return i.Opaque()
  36. }
  37. return false
  38. }