From: griest-tom@cs.yale.edu (Tom Griest)
Cc: thompsor@admin.tc.faa.gov
Subject: Re: .PCX parser. In Ada of course...
Date: 1996/03/23
Date: 1996-03-23T00:00:00+00:00 [thread overview]
Message-ID: <4j28cqINNbke@RA.DEPT.CS.YALE.EDU> (raw)
In-Reply-To: 4ius06INNcpe@faatcrl.faa.gov
ron thompson <thompsor@admin.tc.faa.gov> writes:
>
[snip]
>Any brave and fearless Ada programmers out there got an Ada
>written .pcx parser? Know anyone that does?
Here are a couple snippets from an Ada-based PCX (graphics format) parser.
I would send you all the code, but it is pretty tightly intermixed
with display code for Win32. [There is a lot of scaling and zooming, etc.
that is not really related to PCX]. I didn't write this BTW, but it
is LabTek property and you can do what you want with it (providing
you assume all responsibilty).
-Tom
-----------------------------------------------------------------------------
--
-- This is the PCX header and associated types/constants for processing the
-- file.
--
repeat_signature : constant := 16#C0#;
repeat_count_mask : constant := 16#3F#;
type PALETTE_TYPE is array(0..47) of BYTE;
type RESERVED_TYPE is array(0..57) of BYTE;
type PCX_HEADER_RECORD is record -- should use a rep spec to be safe!
MANUFACTURER : BYTE;
VERSION : BYTE;
ENCODING : BYTE;
BITS_PER_PIXEL : BYTE;
XMIN : SHORT; -- always 16 bits
YMIN : SHORT;
XMAX : SHORT;
YMAX : SHORT;
HRES : SHORT;
VRES : SHORT;
PALETTE : PALETTE_TYPE;
RESERVED_1 : BYTE;
NUM_PLANES : BYTE;
BYTES_PER_LINE : SHORT;
TYPE_OF_PALETTE : SHORT;
RESERVED_2 : RESERVED_TYPE;
end record;
-- main PCX decode loop
INDEX := 0;
for ROW in 0..Y_LIMIT loop
WY := Scale(ROW - Y_OFFSET, Y_SCALE);
X := 0;
loop
VALUE := PCX_BYTES(INDEX);
INDEX := INDEX + 1;
if (VALUE and repeat_signature) = repeat_signature then
COUNT := VALUE and repeat_count_mask;
if ROW >= Y_OFFSET then
VALUE := PCX_BYTES(INDEX);
for I in 1..COUNT loop
if X >= X_OFFSET and
X < X_LIMIT then
Display_Byte(DISPLAY_HDC,
INSTANCE_INDEX,
VALUE,
X - X_OFFSET,
WY);
end if;
X := X + 8;
end loop;
else -- not in the Y_OFFSET range yet
X := X + 8 * INT(COUNT);
end if;
INDEX := INDEX + 1;
else
if ROW >= Y_OFFSET and
X >= X_OFFSET and
X < X_LIMIT then
Display_Byte(DISPLAY_HDC,
INSTANCE_INDEX,
VALUE,
X - X_OFFSET,
WY);
end if;
X := X + 8;
end if;
exit when X >= BITS_PER_LINE;
end loop;
end loop;
prev parent reply other threads:[~1996-03-23 0:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-03-22 0:00 .PCX parser. In Ada of course ron thompson
1996-03-23 0:00 ` Tom Griest [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox