* Some cleanup for Image types
This commit is contained in:
parent
9fdb601669
commit
b0b1ec003d
|
@ -8,17 +8,17 @@ package Video.Images.Raster.ARGB is
|
|||
|
||||
type ARGB_Raster_Image is limited interface and Raster_Image;
|
||||
|
||||
package ARGB1555 is new Generic_Raster_Images (
|
||||
package ARGB1555 is new Generic_Raster (
|
||||
Pixel_Type => ARGB1555_Pixel,
|
||||
Array_Type => ARGB1555_Array,
|
||||
Parent => ARGB_Raster_Image);
|
||||
|
||||
package ARGB4444 is new Generic_Raster_Images (
|
||||
package ARGB4444 is new Generic_Raster (
|
||||
Pixel_Type => ARGB4444_Pixel,
|
||||
Array_Type => ARGB4444_Array,
|
||||
Parent => ARGB_Raster_Image);
|
||||
|
||||
package ARGB8888 is new Generic_Raster_Images (
|
||||
package ARGB8888 is new Generic_Raster (
|
||||
Pixel_Type => ARGB8888_Pixel,
|
||||
Array_Type => ARGB8888_Array,
|
||||
Parent => ARGB_Raster_Image);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
--
|
||||
|
||||
generic
|
||||
with package Raster_Images is new Generic_Raster_Images (<>);
|
||||
with package Raster_Images is new Generic_Raster (<>);
|
||||
type Parent is abstract tagged private;
|
||||
with function Map_Color (Map : Parent; Pixel : Raster_Images.Pixel_Type) return Color is <>;
|
||||
package Video.Images.Raster.Generic_Fixed is
|
||||
|
|
|
@ -5,7 +5,7 @@ with Ada.Containers.Indefinite_Holders;
|
|||
with Video.Pixels.Generic_Holders;
|
||||
|
||||
generic
|
||||
with package Raster_Images is new Generic_Raster_Images (<>);
|
||||
with package Raster_Images is new Generic_Raster (<>);
|
||||
type Parent is abstract tagged private;
|
||||
with function Map_Color (Map : Parent; Pixel : Raster_Images.Pixel_Type) return Color is <>;
|
||||
package Video.Images.Raster.Generic_Unbounded is
|
||||
|
|
|
@ -8,7 +8,7 @@ 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_Images (
|
||||
with package Raster_Images is new Generic_Raster (
|
||||
Pixel_Type => Pixel_Type,
|
||||
Array_Type => Array_Type,
|
||||
Parent => Indexed_Raster_Image);
|
||||
|
|
|
@ -7,7 +7,7 @@ with Video.Images.Raster.Generic_Unbounded;
|
|||
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_Images (
|
||||
with package Raster_Images is new Generic_Raster (
|
||||
Pixel_Type => Pixel_Type,
|
||||
Array_Type => Array_Type,
|
||||
Parent => Indexed_Raster_Image);
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
package body Video.Images.Raster.Indexed is
|
||||
|
||||
function Map_Color (
|
||||
Source : Image_with_Shared_Palette;
|
||||
Index : Color_Index)
|
||||
return Color
|
||||
is (Source.Color_Map (Index));
|
||||
|
||||
function To_Palette (
|
||||
Source : Image_with_Shared_Palette)
|
||||
return Palette
|
||||
is (Source.Color_Map.all);
|
||||
|
||||
end Video.Images.Raster.Indexed;
|
|
@ -13,44 +13,24 @@ package Video.Images.Raster.Indexed is
|
|||
return Color_Index is abstract;
|
||||
-- A pixel index value, an untyped way to read it
|
||||
|
||||
-- note: Function is named `Pixel_Index` to avoid mixed it with `Pixel` group
|
||||
-- note: Function is named `Pixel_Index` to avoid confusing with `Pixel` group
|
||||
-- As it returns integer type it can break type safety
|
||||
|
||||
type Image_with_Shared_Palette is abstract new Controlled and Indexed_Raster_Image with private;
|
||||
-- Base for Image using externally provided palette
|
||||
|
||||
-- Descend from controlled: there likely to be controlled types in the class
|
||||
|
||||
overriding function Map_Color (
|
||||
Source : Image_with_Shared_Palette;
|
||||
Index : Color_Index)
|
||||
return Color;
|
||||
|
||||
function To_Palette (
|
||||
Source : Image_with_Shared_Palette)
|
||||
return Palette;
|
||||
|
||||
--
|
||||
|
||||
package Index_1 is new Generic_Raster_Images (
|
||||
package Index_1 is new Generic_Raster (
|
||||
Pixel_Type => Index_1_Pixel,
|
||||
Array_Type => Index_1_Array,
|
||||
Parent => Indexed_Raster_Image);
|
||||
|
||||
package Index_4 is new Generic_Raster_Images (
|
||||
package Index_4 is new Generic_Raster (
|
||||
Pixel_Type => Index_4_Pixel,
|
||||
Array_Type => Index_4_Array,
|
||||
Parent => Indexed_Raster_Image);
|
||||
|
||||
package Index_8 is new Generic_Raster_Images (
|
||||
package Index_8 is new Generic_Raster (
|
||||
Pixel_Type => Index_8_Pixel,
|
||||
Array_Type => Index_8_Array,
|
||||
Parent => Indexed_Raster_Image);
|
||||
|
||||
private
|
||||
|
||||
type Image_with_Shared_Palette is abstract new Controlled and Indexed_Raster_Image with record
|
||||
Color_Map : access constant Palette;
|
||||
end record;
|
||||
|
||||
end Video.Images.Raster.Indexed;
|
||||
|
|
|
@ -7,7 +7,7 @@ generic
|
|||
type Pixel_Type is private;
|
||||
type Array_Type is array (Integer range <>, Integer range <>) of Pixel_Type;
|
||||
with function To_Color (Pixel : Pixel_Type) return Color is <>;
|
||||
with package Raster_Images is new Generic_Raster_Images (
|
||||
with package Raster_Images is new Generic_Raster (
|
||||
Pixel_Type => Pixel_Type,
|
||||
Array_Type => Array_Type,
|
||||
Parent => RGB_Raster_Image);
|
||||
|
|
|
@ -7,7 +7,7 @@ generic
|
|||
type Pixel_Type is private;
|
||||
type Array_Type is array (Integer range <>, Integer range <>) of Pixel_Type;
|
||||
with function To_Color (Pixel : Pixel_Type) return Color is <>;
|
||||
with package Raster_Images is new Generic_Raster_Images (
|
||||
with package Raster_Images is new Generic_Raster (
|
||||
Pixel_Type => Pixel_Type,
|
||||
Array_Type => Array_Type,
|
||||
Parent => RGB_Raster_Image);
|
||||
|
|
|
@ -8,12 +8,12 @@ package Video.Images.Raster.RGB is
|
|||
|
||||
type RGB_Raster_Image is limited interface and Raster_Image;
|
||||
|
||||
package RGB565 is new Generic_Raster_Images (
|
||||
package RGB565 is new Generic_Raster (
|
||||
Pixel_Type => RGB565_Pixel,
|
||||
Array_Type => RGB565_Array,
|
||||
Parent => RGB_Raster_Image);
|
||||
|
||||
package RGB888 is new Generic_Raster_Images (
|
||||
package RGB888 is new Generic_Raster (
|
||||
Pixel_Type => RGB888_Pixel,
|
||||
Array_Type => RGB888_Array,
|
||||
Parent => RGB_Raster_Image);
|
||||
|
|
|
@ -2,63 +2,7 @@
|
|||
-- Raster Image that is a regular grid of discrete pixels
|
||||
--
|
||||
|
||||
with Video.Integer_Geometry, Video.Colors;
|
||||
use Video.Integer_Geometry, Video.Colors;
|
||||
|
||||
package Video.Images.Raster is
|
||||
|
||||
type Raster_Image is limited interface and Image;
|
||||
-- Root type for raster images
|
||||
|
||||
function Bounding_Box (
|
||||
Source : Raster_Image)
|
||||
return Box is abstract;
|
||||
-- Raster bounds in pixels
|
||||
|
||||
function Pixel (
|
||||
Source : Raster_Image;
|
||||
A : Point)
|
||||
return Color is abstract;
|
||||
-- Color of an individual pixel
|
||||
|
||||
-- A helper generic package to keep types with the same format togeter
|
||||
|
||||
generic
|
||||
type Pixel_Type is private;
|
||||
type Array_Type is array (Integer range <>, Integer range <>) of Pixel_Type;
|
||||
type Parent is limited interface and Raster_Image;
|
||||
package Generic_Raster_Images is
|
||||
|
||||
-- Alias them so external code can use them
|
||||
|
||||
type Image is limited interface and Parent;
|
||||
-- A raster image those pixel type is defined
|
||||
|
||||
--function Map_Color (
|
||||
-- Source : Image;
|
||||
-- Pixel : Pixel_Type) return Color is abstract;
|
||||
|
||||
function Pixel (
|
||||
Source : Image;
|
||||
A : Point) return Pixel_Type is abstract;
|
||||
-- Get a single pixel
|
||||
|
||||
procedure Query_Raster (
|
||||
Source : in Image;
|
||||
Query : not null access procedure (R : in Array_Type)) is abstract;
|
||||
-- Query actual raster (maybe by chunks, seee below)
|
||||
|
||||
procedure Process_Raster (
|
||||
Target : in out Image;
|
||||
Process : not null access procedure (R : in out Array_Type)) is null;
|
||||
-- Modify actual raster. Might be null for images that are not modifiable.
|
||||
-- Non modifiable image could be declared constant so this call will not compile
|
||||
|
||||
-- If Raster is not used as the main image storage, these subprograms
|
||||
-- may split the data into chunks and call Query/Process several times.
|
||||
-- One time per chuunk. Chunk size could generally depend on available RAM
|
||||
-- for temporary storage.
|
||||
|
||||
end Generic_Raster_Images;
|
||||
|
||||
end Video.Images.Raster;
|
||||
|
|
|
@ -1,10 +1,71 @@
|
|||
--
|
||||
-- Handling for images, say sources of graphic information.
|
||||
--
|
||||
with Video.Integer_Geometry, Video.Colors;
|
||||
use Video.Integer_Geometry, Video.Colors;
|
||||
|
||||
package Video.Images with Pure is
|
||||
|
||||
type Image is limited interface;
|
||||
-- The interface for image
|
||||
-- (Not file format, but vector/raster, various pixel types etc.)
|
||||
|
||||
function Bounding_Box (
|
||||
Source : Image)
|
||||
return Box is abstract;
|
||||
-- Image bounds in native (whatever it means) resolution
|
||||
|
||||
function Pixel (
|
||||
Source : Image;
|
||||
A : Point)
|
||||
return Color is abstract;
|
||||
-- Color of an individual pixel in native resolution
|
||||
-- Generally it is an average color for (X .. X + 1, T .. Y + 1) square
|
||||
|
||||
type Raster_Image is limited interface and Image;
|
||||
-- Root type for raster images
|
||||
|
||||
-- A helper generic package to keep types with the same format togeter
|
||||
|
||||
generic
|
||||
type Pixel_Type is private;
|
||||
type Array_Type is array (Integer range <>, Integer range <>) of Pixel_Type;
|
||||
type Parent is limited interface and Raster_Image;
|
||||
package Generic_Raster is
|
||||
|
||||
-- Alias them so external code can use them
|
||||
|
||||
-- Passing Parent allow added level of hierarchy
|
||||
-- Indexed, RGB etc images are grouped
|
||||
|
||||
type Image is limited interface and Parent;
|
||||
-- A raster image those pixel type is defined
|
||||
|
||||
--function Map_Color (
|
||||
-- Source : Image;
|
||||
-- Pixel : Pixel_Type) return Color is abstract;
|
||||
|
||||
function Pixel (
|
||||
Source : Image;
|
||||
A : Point) return Pixel_Type is abstract;
|
||||
-- Get a single pixel
|
||||
|
||||
procedure Query_Raster (
|
||||
Source : in Image;
|
||||
Query : not null access procedure (R : in Array_Type)) is abstract;
|
||||
-- Query actual raster (maybe by chunks, seee below)
|
||||
|
||||
procedure Process_Raster (
|
||||
Target : in out Image;
|
||||
Process : not null access procedure (R : in out Array_Type)) is null;
|
||||
-- Modify actual raster. Might be null for images that are not modifiable.
|
||||
-- Non modifiable image could be declared constant so this call will not compile
|
||||
|
||||
-- If Raster is not used as the main image storage, these subprograms
|
||||
-- may split the data into chunks and call Query/Process several times.
|
||||
-- One time per chuunk. Chunk size could generally depend on available RAM
|
||||
-- for temporary storage.
|
||||
|
||||
end Generic_Raster;
|
||||
|
||||
end Video.Images;
|
||||
|
|
Loading…
Reference in New Issue