Video_library/source/base/video-images-raster-indexed-generic_fixed.ads

59 lines
1.8 KiB
Ada
Raw Normal View History

2023-01-24 23:58:22 +01:00
--
-- Indexed color images with fixed raster not using dynamic storage allocation
--
2023-01-20 17:13:35 +01:00
with Video.Images.Raster.Generic_Fixed;
2023-02-12 23:15:59 +01:00
with Video.Colors.Maps.Generic_Fixed;
with Video.Colors.Maps.Shared_Palettes;
2023-01-20 17:13:35 +01:00
generic
type Pixel_Type is mod <>;
2023-07-29 21:24:23 +02:00
type Array_Type is array (Integer range <>, Integer range <>) of Pixel_Type;
2023-08-03 17:55:45 +02:00
with package Raster_Images is new Generic_Raster (
2023-07-29 21:24:23 +02:00
Pixel_Type => Pixel_Type,
Array_Type => Array_Type,
Parent => Indexed_Raster_Image);
2023-02-05 22:47:43 +01:00
package Video.Images.Raster.Indexed.Generic_Fixed is
Last_Color_Index : constant Color_Index := Color_Index (Pixel_Type'Modulus - 1);
2023-01-24 23:58:22 +01:00
-- Last color index. Used for palette bounds
2023-01-20 17:28:01 +01:00
2023-02-13 00:18:20 +01:00
generic
type Parent_Color_Map is new Video.Colors.Maps.Constant_Color_Map with private;
package Images_with_Color_Map is
type Base_Color_Map is abstract new Parent_Color_Map with null record;
2023-02-05 22:47:43 +01:00
2023-02-13 00:18:20 +01:00
function Map_Color (Map : Base_Color_Map; Pixel : Pixel_Type) return Color
is (Map.Map_Color (Color_Index (Pixel))) with Inline;
2023-02-12 23:15:59 +01:00
2023-02-13 00:18:20 +01:00
package Image_Base is new Raster.Generic_Fixed (
Raster_Images => Raster_Images,
Parent => Base_Color_Map);
2023-02-12 23:15:59 +01:00
2023-02-13 00:18:20 +01:00
type Image is new Image_Base.Image with null record;
-- An actual type
2023-01-20 17:13:35 +01:00
2023-02-13 00:18:20 +01:00
overriding function Pixel_Index (
Source : Image;
A : Point)
return Natural
is (Integer (Source.Pixels (A.Y, A.X)));
2023-02-13 00:18:20 +01:00
end Images_with_Color_Map;
--
2023-02-13 00:18:20 +01:00
package Fixed_Color_Maps is new Colors.Maps.Generic_Fixed (0, Last_Color_Index);
package With_Own_Palette is new Images_with_Color_Map (Fixed_Color_Maps.Fixed_Color_Map);
subtype Image_with_Own_Palette is With_Own_Palette.Image;
--
2023-01-20 17:28:01 +01:00
2023-02-13 00:18:20 +01:00
package With_Shared_Palette is new Images_with_Color_Map (
Colors.Maps.Shared_Palettes.Constant_Shared_Palette);
2023-02-13 00:18:20 +01:00
subtype Image_with_Shared_Palette is With_Shared_Palette.Image;
2023-01-20 17:13:35 +01:00
end Video.Images.Raster.Indexed.Generic_Fixed;