From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d2b975cce1562a98 X-Google-Attributes: gid103376,public From: griest-tom@cs.yale.edu (Tom Griest) Subject: Re: .PCX parser. In Ada of course... Date: 1996/03/23 Message-ID: <4j28cqINNbke@RA.DEPT.CS.YALE.EDU>#1/1 X-Deja-AN: 143959595 references: <4ius06INNcpe@faatcrl.faa.gov> organization: Yale University Computer Science Dept., New Haven, CT 06520-2158 cc: thompsor@admin.tc.faa.gov keywords: PCX, Ada95 newsgroups: comp.lang.ada Date: 1996-03-23T00:00:00+00:00 List-Id: ron thompson 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;