mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-20 14:39:00 +00:00
Add TestImageRGB888 and TestImageRGB555
This commit is contained in:
@@ -9,6 +9,27 @@ import (
|
|||||||
"tinygo.org/x/drivers/pixel"
|
"tinygo.org/x/drivers/pixel"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestImageRGB888(t *testing.T) {
|
||||||
|
image := pixel.NewImage[pixel.RGB888](5, 3)
|
||||||
|
if width, height := image.Size(); width != 5 || height != 3 {
|
||||||
|
t.Errorf("image.Size(): expected 5, 3 but got %d, %d", width, height)
|
||||||
|
}
|
||||||
|
for _, c := range []color.RGBA{
|
||||||
|
{R: 0xff, A: 0xff},
|
||||||
|
{G: 0xff, A: 0xff},
|
||||||
|
{B: 0xff, A: 0xff},
|
||||||
|
{R: 0x10, A: 0xff},
|
||||||
|
{G: 0x10, A: 0xff},
|
||||||
|
{B: 0x10, A: 0xff},
|
||||||
|
} {
|
||||||
|
image.Set(4, 2, pixel.NewColor[pixel.RGB888](c.R, c.G, c.B))
|
||||||
|
c2 := image.Get(4, 2).RGBA()
|
||||||
|
if c2 != c {
|
||||||
|
t.Errorf("failed to roundtrip color: expected %v but got %v", c, c2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestImageRGB565BE(t *testing.T) {
|
func TestImageRGB565BE(t *testing.T) {
|
||||||
image := pixel.NewImage[pixel.RGB565BE](5, 3)
|
image := pixel.NewImage[pixel.RGB565BE](5, 3)
|
||||||
if width, height := image.Size(); width != 5 || height != 3 {
|
if width, height := image.Size(); width != 5 || height != 3 {
|
||||||
@@ -30,6 +51,27 @@ func TestImageRGB565BE(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestImageRGB555(t *testing.T) {
|
||||||
|
image := pixel.NewImage[pixel.RGB555](5, 3)
|
||||||
|
if width, height := image.Size(); width != 5 || height != 3 {
|
||||||
|
t.Errorf("image.Size(): expected 5, 3 but got %d, %d", width, height)
|
||||||
|
}
|
||||||
|
for _, c := range []color.RGBA{
|
||||||
|
{R: 0xff, A: 0xff},
|
||||||
|
{G: 0xff, A: 0xff},
|
||||||
|
{B: 0xff, A: 0xff},
|
||||||
|
{R: 0x10, A: 0xff},
|
||||||
|
{G: 0x10, A: 0xff},
|
||||||
|
{B: 0x10, A: 0xff},
|
||||||
|
} {
|
||||||
|
image.Set(4, 2, pixel.NewColor[pixel.RGB555](c.R, c.G, c.B))
|
||||||
|
c2 := image.Get(4, 2).RGBA()
|
||||||
|
if c2 != c {
|
||||||
|
t.Errorf("failed to roundtrip color: expected %v but got %v", c, c2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestImageRGB444BE(t *testing.T) {
|
func TestImageRGB444BE(t *testing.T) {
|
||||||
image := pixel.NewImage[pixel.RGB444BE](5, 3)
|
image := pixel.NewImage[pixel.RGB444BE](5, 3)
|
||||||
if width, height := image.Size(); width != 5 || height != 3 {
|
if width, height := image.Size(); width != 5 || height != 3 {
|
||||||
|
|||||||
Reference in New Issue
Block a user