text
stringlengths
0
234
end loop;
-- Load the image descriptor
Read_Intel(image.buffer, Descriptor.ImageLeft);
Read_Intel(image.buffer, Descriptor.ImageTop);
Read_Intel(image.buffer, Descriptor.ImageWidth);
Read_Intel(image.buffer, Descriptor.ImageHeight);
Get_Byte(image.buffer, Descriptor.Depth);
Raw_Byte(Descriptor.Depth);
-- Get image corner coordinates
tlX := Natural(Descriptor.ImageLeft);
tlY := Natural(Descriptor.ImageTop);
brX := tlX + Natural(Descriptor.ImageWidth);
brY := tlY + Natural(Descriptor.ImageHeight);
-- Local Color Table Flag 1 Bit
-- Interlace Flag 1 Bit
-- Sort Flag 1 Bit
-- Reserved 2 Bits
-- Size of Local Color Table 3 Bits
--
frame_interlaced:= (Descriptor.Depth and 64) = 64;
local_palette:= (Descriptor.Depth and 128) = 128;
local.format:= GIF;
local.stream:= image.stream;
local.buffer:= image.buffer;
if local_palette then
-- Get amount of colours in image
BitsPerPixel := 1 + Natural(Descriptor.Depth and 7);
new_num_of_colours:= 2 ** BitsPerPixel;
-- 21. Local Color Table
local.palette:= new Color_table(0..new_num_of_colours-1);
Color_tables.Load_palette(local);
image.buffer:= local.buffer;
elsif image.palette = null then
Raise_Exception(
error_in_image_data'Identity,
"GIF: neither local, nor global palette"
);
else
-- Use global palette
new_num_of_colours:= 2 ** image.subformat_id;
-- usually <= 2** image.bits_per_pixel
-- Just copy main palette
local.palette:= new Color_table'(image.palette.all);
end if;
pixel_mask:= U32(new_num_of_colours - 1);
if full_trace then
Ada.Text_IO.Put_Line(
" - Image, interlaced: " & Boolean'Image(frame_interlaced) &
"; local palette: " & Boolean'Image(local_palette) &
"; transparency: " & Boolean'Image(frame_transparency) &
"; transparency index:" & Color_type'Image(Transp_color)
);
end if;
-- Get initial code size
Get_Byte(image.buffer, temp );
Raw_Byte(temp);
if Natural(temp) not in Code_size_range then
Raise_Exception(
error_in_image_data'Identity,
"GIF: wrong LZW code size (must be in 2..12), is" &
U8'Image(temp)
);
end if;
CurrSize := Natural(temp);
-- Start at top left of image
X := Natural(Descriptor.ImageLeft);
Y := Natural(Descriptor.ImageTop);
Set_X_Y(X, image.height - Y - 1);
--
if new_num_of_colours < 256 then
-- "Rare" formats -> no need of best speed
declare
-- We create an instance with dynamic parameters
procedure GIF_Decode_general is
new GIF_Decode(frame_interlaced, frame_transparency, pixel_mask);
begin
GIF_Decode_general;
Function Definition: procedure Register_Tests (T : in out TC) is
Function Body: use AUnit.Test_Cases.Registration;
begin
Register_Routine
(T, Test_One_String'Access, "One string");
Register_Routine
(T, Test_Two_Strings'Access, "Two strings");
end Register_Tests;
procedure Set_Up (T : in out TC) is
begin
T.P.Create (128);
end Set_Up;
function Name (T : TC) return Message_String is
pragma Unreferenced (T);