107 lines
3.0 KiB
Ada
107 lines
3.0 KiB
Ada
with Video.Colors;
|
|
use Video.Colors;
|
|
|
|
--
|
|
-- RGB rasters
|
|
--
|
|
package Video.Rasters.RGB is
|
|
|
|
-- Pixel formats
|
|
-- 1 1 1 1 1 1
|
|
-- 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
|
|
-- +---------+-----------+---------+
|
|
-- | R | G | B | RGB565 (aka RGB16)
|
|
-- +---------+-----------+---------+
|
|
-- +-+---------+---------+---------+
|
|
-- |A| R | G | B | ARGB1555
|
|
-- +-+---------+---------+---------+
|
|
-- 2 2 2 2 1 1 1 1 1 1 1 1 1 1
|
|
-- 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
|
|
-- +---------------+---------------+---------------+
|
|
-- | R | G | B | RGB888 (aka RGB24)
|
|
-- +---------------+---------------+---------------+
|
|
-- 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
|
|
-- 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
|
|
-- +---------------+---------------+---------------+---------------+
|
|
-- | A | R | G | B | ARGB8888 (aka ARGB32)
|
|
-- +---------------+---------------+---------------+---------------+
|
|
|
|
-- RGB565
|
|
|
|
type RGB565_Pixel is record
|
|
R : Integer range 0 .. 2**5 - 1;
|
|
G : Integer range 0 .. 2**6 - 1;
|
|
B : Integer range 0 .. 2**5 - 1;
|
|
end record with Size => 16;
|
|
for RGB565_Pixel use record
|
|
R at 0 range 11 .. 15;
|
|
G at 0 range 5 .. 10;
|
|
B at 0 range 0 .. 4;
|
|
end record;
|
|
|
|
function RGB_8 (
|
|
R, G, B : Color_Component_8_Bit)
|
|
return RGB565_Pixel
|
|
is ((R => R / 8, G => G / 4, B => B / 8))
|
|
with Inline;
|
|
|
|
type RGB565_Raster is array (Integer range <>, Integer range <>) of RGB565_Pixel;
|
|
|
|
-- ARGB1555
|
|
|
|
type ARGB1555_Pixel is record
|
|
R : Integer range 0 .. 2**5 - 1;
|
|
G : Integer range 0 .. 2**5 - 1;
|
|
B : Integer range 0 .. 2**5 - 1;
|
|
A : Integer range 0 .. 1;
|
|
end record with Size => 16;
|
|
for ARGB1555_Pixel use record
|
|
R at 0 range 10 .. 14;
|
|
G at 0 range 5 .. 9;
|
|
B at 0 range 0 .. 4;
|
|
A at 0 range 15 .. 15;
|
|
end record;
|
|
|
|
function RGB_8 (
|
|
R, G, B : Color_Component_8_Bit;
|
|
A : Color_component_8_Bit := Color_Component_8_Bit'Last)
|
|
return ARGB1555_Pixel
|
|
is ((R => R / 8, G => G / 8, B => B / 8, A => A / 128))
|
|
with Inline;
|
|
|
|
type ARGB1555_Raster is array (Integer range <>, Integer range <>) of ARGB1555_Pixel;
|
|
|
|
-- RGB888
|
|
|
|
type RGB888_Pixel is record
|
|
R : Integer range 0 .. 2**8 - 1;
|
|
G : Integer range 0 .. 2**8 - 1;
|
|
B : Integer range 0 .. 2**8 - 1;
|
|
end record with Size => 24;
|
|
for RGB888_Pixel use record
|
|
R at 0 range 16 .. 23;
|
|
G at 0 range 8 .. 15;
|
|
B at 0 range 0 .. 7;
|
|
end record;
|
|
|
|
type RGB888_Raster is array (Integer range <>, Integer range <>) of RGB888_Pixel;
|
|
|
|
-- ARGB8888
|
|
|
|
type ARGB8888_Pixel is record
|
|
R : Integer range 0 .. 2**8 - 1;
|
|
G : Integer range 0 .. 2**8 - 1;
|
|
B : Integer range 0 .. 2**8 - 1;
|
|
A : Integer range 0 .. 2**8 - 1;
|
|
end record with Size => 32;
|
|
for ARGB8888_Pixel use record
|
|
R at 0 range 16 .. 23;
|
|
G at 0 range 8 .. 15;
|
|
B at 0 range 0 .. 7;
|
|
A at 0 range 24 .. 31;
|
|
end record;
|
|
|
|
type ARGB8888_Raster is array (Integer range <>, Integer range <>) of ARGB8888_Pixel;
|
|
|
|
end Video.Rasters.RGB;
|