delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/04/10:04:46

From: xmerm05 AT vse DOT cz (Michal Mertl)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: pcx file format questions
Date: Mon, 1 Sep 1997 13:35:05
Organization: University of Economics - Prague, CZ
Lines: 40
Message-ID: <xmerm05.22.000D95B6@vse.cz>
References: <Pine DOT SGI DOT 3 DOT 91 DOT 970831001741 DOT 3300A-100000 AT neutrino DOT phys DOT laurentian DOT ca>
NNTP-Posting-Host: s018h07.vse.cz
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Timothy Robb wrote:
>I have a pcx class I am writting  and have some questions about pcx file 
>format in general.

>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.)
BytesPerLine is the amount of memory you will need to store one line. It
can be calculated like (width+1)*(BitsPerPixel%8)?(BitsPerPixel/8+1):(
(BitsPerPixel/8). And should be divisible by 2 (odd?).

>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);
It's ok.

>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];
>};
Do you use DJGPP? I would be surprised if this works without 
__attributte__ ((packed)) after each line in struct because GCC aligns 
variables in structs on 32bit boundary, so that PCX header'd much bigger 
than expected.

Michal 'MiMe' Mertl
e-mail:XMERM05 AT vse DOT cz

- Raw text -


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