comp.lang.ada
 help / color / mirror / Atom feed
* .PCX parser. In Ada of course...
@ 1996-03-22  0:00 ron thompson
  1996-03-23  0:00 ` Tom Griest
  0 siblings, 1 reply; 2+ messages in thread
From: ron thompson @ 1996-03-22  0:00 UTC (permalink / raw)



We are working on some hardware that will ultimately ship some
topographical type data provided in the venerable pcx format.

Ours is a small effort of no great consequence.

There appears to be some confusion on our part over the .pcx
file format documentation, which is also of no great
consequence as we will get over it.

This confusion led to me getting a bunch of stuff regarding
pcx readers/writers etc, all in that other language that
has only one letter and two mathematical operators.

I can't read that crap.

Any brave and fearless Ada programmers out there got an Ada
written .pcx parser? Know anyone that does? 

Mail me if you want to. But don't bother me with anything
regarding me not being able to read that crap. Your efforts
will be wasted.

Thank you.

rct

The opinions above are mine, and mine alone.





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: .PCX parser. In Ada of course...
  1996-03-22  0:00 .PCX parser. In Ada of course ron thompson
@ 1996-03-23  0:00 ` Tom Griest
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Griest @ 1996-03-23  0:00 UTC (permalink / raw)
  Cc: thompsor

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;




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1996-03-23  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-03-22  0:00 .PCX parser. In Ada of course ron thompson
1996-03-23  0:00 ` Tom Griest

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox