func (c GrayAM) RGBA() (r, g, b, a uint32) {
	m := uint32(c.M)
	a = (uint32(c.A)*0xffff + m/2) / m
	y := (uint32(c.Y)*a + m/2) / m
	return y, y, y, a
}
RGBA converts a GrayAM to alpha-premultiplied R, G, B, and A.
package npcolor
import (
	"image/color"
)
type GrayM struct {
	Y, M uint8
}
func (c GrayM) RGBA() (r, g, b, a uint32) {
	m := uint32(c.M)
	y := (uint32(c.Y)*0xffff + m/2) / m
	return y, y, y, 0xffff
}
type GrayMModel struct {
	M uint8  
}
func (model GrayMModel) Convert(c color.Color) color.Color {
	if gray, ok := c.(GrayM); ok && gray.M == model.M {
		return c
	}
	r, g, b, _ := c.RGBA()
	y := (299*r + 587*g + 114*b + 500) / 1000
	m := uint32(model.M)
	y = (y*m + 0xffff/2) / 0xffff
	return GrayM{Y: uint8(y), M: uint8(m)}
}
type GrayM32 struct {
	Y, M uint16
}
func (c GrayM32) RGBA() (r, g, b, a uint32) {
	m := uint32(c.M)
	y := (uint32(c.Y)*0xffff + m/2) / m
	return y, y, y, 0xffff
}
type GrayM32Model struct {
	M uint16  
}
func (model GrayM32Model) Convert(c color.Color) color.Color {
	if gray, ok := c.(GrayM32); ok && gray.M == model.M {
		return c
	}
	r, g, b, _ := c.RGBA()
	y := (299*r + 587*g + 114*b + 500) / 1000
	m := uint32(model.M)
	y = (y*m + 0xffff/2) / 0xffff
	return GrayM32{Y: uint16(y), M: uint16(m)}
}
type RGBM struct {
	R, G, B, M uint8
}
func (c RGBM) RGBA() (r, g, b, a uint32) {
	m := uint32(c.M)
	r = (uint32(c.R)*0xffff + m/2) / m
	g = (uint32(c.G)*0xffff + m/2) / m
	b = (uint32(c.B)*0xffff + m/2) / m
	a = 0xffff
	return
}
type RGBMModel struct {
	M uint8  
}
func (model RGBMModel) Convert(c color.Color) color.Color {
	if rgb, ok := c.(RGBM); ok && rgb.M == model.M {
		return c
	}
	m := uint32(model.M)
	r, g, b, _ := c.RGBA()
	const half = 0xffff / 2
	r = (r*m + half) / 0xffff
	g = (g*m + half) / 0xffff
	b = (b*m + half) / 0xffff
	return RGBM{R: uint8(r), G: uint8(g), B: uint8(b), M: uint8(m)}
}
type RGBM64 struct {
	R, G, B, M uint16
}
func (c RGBM64) RGBA() (r, g, b, a uint32) {
	m := uint32(c.M)
	r = (uint32(c.R)*0xffff + m/2) / m
	g = (uint32(c.G)*0xffff + m/2) / m
	b = (uint32(c.B)*0xffff + m/2) / m
	a = 0xffff
	return
}
type RGBM64Model struct {
	M uint16  
}
func (model RGBM64Model) Convert(c color.Color) color.Color {
	if rgb, ok := c.(RGBM64); ok && rgb.M == model.M {
		return c
	}
	m := uint32(model.M)
	r, g, b, _ := c.RGBA()
	const half = 0xffff / 2
	r = (r*m + half) / 0xffff
	g = (g*m + half) / 0xffff
	b = (b*m + half) / 0xffff
	return RGBM64{R: uint16(r), G: uint16(g), B: uint16(b), M: uint16(m)}
}
type GrayAM struct {
	Y, A, M uint8
}