59 lines
1.8 KiB
Ada
59 lines
1.8 KiB
Ada
--
|
|
-- Indexed color images with fixed raster not using dynamic storage allocation
|
|
--
|
|
with Video.Images.Raster.Generic_Fixed;
|
|
with Video.Colors.Maps.Generic_Fixed;
|
|
with Video.Colors.Maps.Shared_Palettes;
|
|
|
|
generic
|
|
type Pixel_Type is mod <>;
|
|
type Array_Type is array (Integer range <>, Integer range <>) of Pixel_Type;
|
|
with package Raster_Images is new Generic_Raster (
|
|
Pixel_Type => Pixel_Type,
|
|
Array_Type => Array_Type,
|
|
Parent => Indexed_Raster_Image);
|
|
package Video.Images.Raster.Indexed.Generic_Fixed is
|
|
|
|
Last_Color_Index : constant Color_Index := Color_Index (Pixel_Type'Modulus - 1);
|
|
-- Last color index. Used for palette bounds
|
|
|
|
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;
|
|
|
|
function Map_Color (Map : Base_Color_Map; Pixel : Pixel_Type) return Color
|
|
is (Map.Map_Color (Color_Index (Pixel))) with Inline;
|
|
|
|
package Image_Base is new Raster.Generic_Fixed (
|
|
Raster_Images => Raster_Images,
|
|
Parent => Base_Color_Map);
|
|
|
|
type Image is new Image_Base.Image with null record;
|
|
-- An actual type
|
|
|
|
overriding function Pixel_Index (
|
|
Source : Image;
|
|
A : Point)
|
|
return Natural
|
|
is (Integer (Source.Pixels (A.Y, A.X)));
|
|
|
|
end Images_with_Color_Map;
|
|
|
|
--
|
|
|
|
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;
|
|
|
|
--
|
|
|
|
package With_Shared_Palette is new Images_with_Color_Map (
|
|
Colors.Maps.Shared_Palettes.Constant_Shared_Palette);
|
|
|
|
subtype Image_with_Shared_Palette is With_Shared_Palette.Image;
|
|
|
|
end Video.Images.Raster.Indexed.Generic_Fixed;
|