Mail Archives: djgpp/1997/08/31/00:29:13

Date: Sun, 31 Aug 1997 00:26:41 -0400 (EDT)
From: Timothy Robb <trobb AT neutrino DOT phys DOT laurentian DOT ca>
To: djgpp AT delorie DOT com
Subject: pcx file format questions
Message-ID: <>
MIME-Version: 1.0

I have a pcx class I am writting  and have some questions about pcx file 
format in general.

The header that I'm using is at the end of this message.  My class right 
now has some diagnostic information printed which follows for one of 
my test images called "image.pcx".

Version : 5
Bytes per pixel : 8
x : 0   y : 0
width : 90      height : 100
horz_res : 150
vert_res : 150
number of colour planes : 1
bytes per line : 92
size of image : 9191
image allocated

I take the x resolution of my images to be width-x+1 and my y resolution 
to be height-y+1, x resolution * y resolution give me the image buffer 
size (91*101 = 9191 in this example).  I would like to know what bytes 
per line is?  I would think it's related to the width but am not sure, 
can someone clarify this? (If you need to look at my code I can arrange 
for you to get it.)

btw is it ok to do the following where fp is my file pointer to a pcx file.
  pcx_header header;
  fread(&header, sizeof(header), 1, fp);

Timothy Robb
Serving humanity since 1978

struct pcx_header
  unsigned char manufacturer;     // always 10
  unsigned char version;          // 5 -> version 3.0 or better
  unsigned char encoding;         // 1 -> rle
  unsigned char bytes_per_pixel;  // 8 for me
  short x, y;            // upper leftcorner
  short width, height;   //
  short horz_res;        // pixels in x direction
  short vert_res;        // pixels in y direction
  unsigned char ega_palette[48];  // ignore
  unsigned char reserved;
  unsigned char num_color_planes;
  short bytes_per_line;
  short palette_type;
  unsigned char padding[58];

- Raw text -

  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019