sdl/pixels: add RGB444Model
@@ -339,3 +339,26 @@ func BytesPerPixel(format uint32) int {
func BitsPerPixel(format uint32) int {
return int(C.bitsPerPixel(C.Uint32(format)))
}
+
+type RGB444 struct {
+ R, G, B byte
+}
+
+func (c RGB444) RGBA() (r, g, b, a uint32) {
+ r = uint32(c.R) << 12
+ g = uint32(c.G) << 12
+ b = uint32(c.B) << 12
+ return
+}
+
+var (
+ RGB444Model color.Model = color.ModelFunc(rgb444Model)
+)
+
+func rgb444Model(c color.Color) color.Color {
+ if _, ok := c.(color.RGBA); ok {
+ return c
+ }
+ r, g, b, _ := c.RGBA()
+ return RGB444{uint8(r >> 12), uint8(g >> 12), uint8(b >> 12)}
+}
