Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


displaying bmp/pcx in C

Posted on 1999-07-16
Medium Priority
Last Modified: 2010-04-15
OZOOOO and anyoneee !!!! please hellppp... i know yer good so pleaseee... i need to display bmp or pcx in my program using C... please give me the simplest code of how this can be done !!! a brief explanation about the structure of bmp/pcx would help me a lot !!!
Question by:techpage
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 1263659
And number 4
See Q.10179085

Expert Comment

ID: 1263660
If you want the simplest solution, check out and look for the Allegro Game Library.

Accepted Solution

julian_svirsky earned 400 total points
ID: 1263661
=====FOR PCX=====
First 128 bytes contain this header.

PCXHeader = Record
  OEM      : Byte;
  Version  : Byte;
  RLLEnc   : Boolean;  { Use Run length packing? }
  BPP      : Byte;     { Bits per pixel          }
  X1,Y1,               { Coordinated to Top/left }
  X2,Y2    : Word;     { Bottom/right            }
  HRes,                { Horizontal resolution   }
  VRes     : Word;     { Vertical resolution     }
  Pallete  : Array[1..48] Of Byte;
  VMode    : Byte;     { Prefered VideoMode      }
  Planes   : Byte;     { Number of planes in pic.}
  BPL      : Word;     { Bytes per line          }
  PalINfo  : Word;     { 1-Color/BW 2-GreyScale  }
  HSize    : Word;     { Horizontal screen size in pixels. }
  VSize    : Word;     { Vertical screen size in pixels.  }
  Pad      : Array[74..128] of Byte;

Then for Each Line of Graphics (pcxHeader.Y2-pcxHeader.Y1)
you need to get PLANESxBPL bytes, if RLLEnc then you'll have to expand the
compressed code.  To do this as you pull off a byte (B), Check if the top two
bits are set [ie: (B AND $C0)=$C0] then this is a Count byte clear the top 2
bits (Count := B AND $3F), and this is the number of times the next byte in the
File will be repeated in the picture.

If the PCXheader.version < 5 then you have 16 Colours held in PCXheader.Pallete
held in 16 DAC Recs each with three bytes for Red, Green, and Blue.

If PCXHeader >= 5 then if the next byte is 12 then there is no 256 byte
palette, and you should rely on the Palette field.  Otherwise a 256x3 byte
palette follows, same DAC recs.

===If you want some code examples go to
It has most file formats

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question