text stringlengths 0 234 |
|---|
exit when ch.kind = IEND or ch.length > 0; |
end loop; |
case ch.kind is |
when IEND => -- 11.2.5 IEND Image trailer |
exit main_chunk_loop; |
when IDAT => -- 11.2.4 IDAT Image data |
-- |
-- NB: the compressed data may hold on several IDAT chunks. |
-- It means that right in the middle of compressed data, you |
-- can have a chunk crc, and a new IDAT header!... |
-- |
UnZ_IO.Read_raw_byte(b); -- zlib compression method/flags code |
UnZ_IO.Read_raw_byte(b); -- Additional flags/check bits |
-- |
UnZ_IO.Init_Buffers; |
-- ^ we indicate that we have a byte reserve of chunk's length, |
-- minus both zlib header bytes. |
UnZ_Meth.Inflate; |
z_crc:= 0; |
for i in 1..4 loop |
begin |
UnZ_IO.Read_raw_byte(b); |
exception |
when error_in_image_data => |
-- vicious IEND at the wrong place |
-- basi4a08.png test image (corrupt imho) |
exit main_chunk_loop; |
Function Definition: procedure Read_Intel is new Read_Intel_x86_number( U16 ); |
Function Body: type GIFDescriptor is record |
ImageLeft, |
ImageTop, |
ImageWidth, |
ImageHeight : U16; |
Depth : U8; |
end record; |
-- For loading from the GIF file |
Descriptor : GIFDescriptor; |
-- Coordinates |
X, tlX, brX : Natural; |
Y, tlY, brY : Natural; |
-- Code information |
subtype Code_size_range is Natural range 2..12; |
CurrSize : Code_size_range; |
subtype Color_type is U8; |
Transp_color : Color_type:= 0; |
-- GIF data is stored in blocks and sub-blocks. |
-- We initialize block_read and block_size to force |
-- reading and buffering the next sub-block |
block_size : Natural:= 0; |
block_read : Natural:= 0; |
function Read_Byte return U8 is |
pragma Inline(Read_Byte); |
b: U8; |
begin |
if block_read >= block_size then |
Get_Byte(image.buffer, b); |
Raw_Byte (b); |
block_size:= Natural(b); |
block_read:= 0; |
end if; |
Get_Byte(image.buffer, b); |
Raw_Byte (b); |
block_read:= block_read + 1; |
return b; |
end Read_Byte; |
-- Used while reading the codes |
bits_in : U8:= 8; |
bits_buf: U8; |
-- Local procedure to read the next code from the file |
function Read_Code return Natural is |
bit_mask: Natural:= 1; |
code: Natural:= 0; |
begin |
-- Read the code, bit by bit |
for Counter in reverse 0..CurrSize - 1 loop |
-- Next bit |
bits_in:= bits_in + 1; |
-- Maybe, a new byte needs to be loaded with a further 8 bits |
if bits_in = 9 then |
bits_buf:= Read_Byte; |
bits_in := 1; |
end if; |
-- Add the current bit to the code |
if (bits_buf and 1) > 0 then |
code:= code + bit_mask; |
end if; |
bit_mask := bit_mask * 2; |
bits_buf := bits_buf / 2; |
end loop; |
return code; |
end Read_Code; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.