• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 265
  • Last Modified:

displaying bmp/pcx in C

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 !!!
1 Solution
And number 4
See Q.10179085
If you want the simplest solution, check out http://www.delorie.com/djgpp and look for the Allegro Game Library.
=====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 http://www.fortunecity.com/skyscraper/scanner/26/ind_form.htm===
It has most file formats
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free tool for managing users' photos in Office 365

Easily upload multiple users’ photos to Office 365. Manage them with an intuitive GUI and use handy built-in cropping and resizing options. Link photos with users based on Azure AD attributes. Free tool!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now