home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD Direkt 1995 #1
/
Image.iso
/
cdd
/
winanw
/
pman
/
readpcx.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-03-21
|
16KB
|
345 lines
/************************************************************************\
* *
* readpcx.c *
* *
* This file is part of PICTURE MAN image file converter/processor *
* *
* 1992 Potapov WORKS, STOIK Ltd. *
* *
* This file contains source code for PCX file reader *
* *
* Compiler: MS C v.6.00A *
* *
* You may use, modify and distribute this code freely *
* *
\************************************************************************/
#include <windows.h>
#include "custconv.h"
#define BUFSIZE 4096
#define SEEK_SET 0
#define SEEK_END 2
typedef struct {
int file, bplin, pos, buflen, count;
BYTE byte, buffer[BUFSIZE];
int iCur;
}PCXStruct;
/************************************************************************\
* *
* ROUTINE: int FAR PASCAL LibMain(HANDLE hModule, WORD wDataSeg, *
* WORD cbHeapSize, LPSTR lpszCmdLine) *
* PURPOSE: DLL entry point. *
* *
\************************************************************************/
int FAR PASCAL LibMain(HANDLE hModule, WORD wDataSeg,
WORD cbHeapSize, LPSTR lpszCmdLine)
{
return 1;
}
/************************************************************************\
* *
* ROUTINE: int FAR PASCAL WEP(int bSystemExit) *
* *
* PURPOSE: DLL exit procedure *
* *
\************************************************************************/
int FAR PASCAL WEP(int bSystemExit)
{
return 1;
}
/************************************************************************\
* *
* ROUTINE: WORD FAR PASCAL Magic(void) *
* *
* PURPOSE: Identification routine *
* RETURNS: 'Magic number' SRC_MAGIC *
* *
\************************************************************************/
WORD FAR PASCAL Magic(void)
{
return SRC_MAGIC;
}
/************************************************************************\
* *
* ROUTINE: DWORD FAR PASCAL GetFlags(void) *
* *
* PURPOSE: Sets flag for SetOptions Dialog box *
* *
* PARAMETERS: None *
* *
* RETURNS: *
* INFO_HASOPTIONS if converter supports SetOptions dialog box *
* 0ul otherwise *
* *
\************************************************************************/
DWORD FAR PASCAL GetFlags(void)
{
return 0ul;
}
/************************************************************************\
* *
* ROUTINE: void FAR PASCAL GetDescription(LPSTR str) *
* *
* PURPOSE: Sets format name *
* *
* PARAMETERS: LPSTR str - pointer for format name storage. The length *
* name must be less than 40! *
* *
\************************************************************************/
void FAR PASCAL GetDescription(LPSTR str)
{
lstrcpy(str,"ZSoft PaintBrush PCX");
}
/************************************************************************\
* *
* ROUTINE: void FAR PASCAL GetExtension(LPSTR str) *
* *
* PURPOSE: Sets format file extension *
* *
* PARAMETERS: LPSTR str - pointer for format file extension. *
* *
\************************************************************************/
void FAR PASCAL GetExtension(LPSTR str)
{
lstrcpy(str,"PCX");
}
/************************************************************************\
* *
* ROUTINE: int FAR PASCAL GetPrivateSize() *
* *
* PURPOSE: Returns size of private memory block *
* *
* *
\************************************************************************/
int FAR PASCAL GetPrivateSize()
{
return sizeof(PCXStruct);
}
/************************************************************************/
/************************************************************************/
/************************************************************************/
/* PCX File Header */
typedef struct {
char manuf; /* Always =10 for Paintbrush */
char hard; /* Version information */
char encod; /* Run-length encoding (=1) */
char bitpx; /* Bits per pixel */
unsigned x1; /* Picture dimensions (incl) */
unsigned y1;
unsigned x2;
unsigned y2;
unsigned hres; /* Display horiz resolution */
unsigned vres; /* Display vert resolution */
char clrma[48]; /* Pallete */
char vmode; /* (ignored) */
char nplanes; /* Number of planes (ver 2.5=0)*/
unsigned bplin; /* Bytes per line */
unsigned palinfo; /* Palette Info (1=col, 2=gray)*/
unsigned shres; /* Scanner resolution */
unsigned svres; /* */
char xtra[54]; /* Extra space (filler) */
} pcxheader;
/************************************************************************\
* *
* ROUTINE: int FAR PASCAL ReadHeader(LPINF