home *** CD-ROM | disk | FTP | other *** search
/ CD Direkt 1995 #1 / Image.iso / cdd / winanw / pman / writepcx.c < prev    next >
C/C++ Source or Header  |  1993-03-21  |  23KB  |  474 lines

  1. /************************************************************************\
  2.  *                                                                      *
  3.  *  writepcx.c                                                          *
  4.  *                                                                      *
  5.  *  This file is part of PICTURE MAN image file converter/processor     *
  6.  *                                                                      *
  7.  *  1992 Potapov WORKS, STOIK Ltd.                                      *
  8.  *                                                                      *
  9.  *  This file contains source code for PCX file writer                  *
  10.  *                                                                      *
  11.  *  Compiler: MS C v.6.00A                                              *
  12.  *                                                                      *
  13.  *  You may use, modify and distribute this code freely                 *
  14.  *                                                                      *
  15. \************************************************************************/
  16. #include <windows.h>
  17. #include "custconv.h"
  18.   
  19. #define SEEK_SET    0
  20. #define SEEK_CUR    1
  21. #define SEEK_END    2
  22.   
  23. #define BUFSIZE 4096
  24.   
  25.  
  26. typedef struct {
  27.         char         manuf;     /* Always =10 for Paintbrush   */
  28.         char         hard;      /* Version information         */
  29.         char         encod;     /* Run-length encoding (=1)    */
  30.         char         bitpx;     /* Bits per pixel              */
  31.         unsigned     x1;        /* Picture dimensions (incl)   */
  32.         unsigned     y1;
  33.         unsigned     x2;
  34.         unsigned     y2;
  35.         unsigned     hres;      /* Display horiz resolution    */
  36.         unsigned     vres;      /* Display vert  resolution    */
  37.         char         clrma[48]; /* Pallete                     */
  38.         char         vmode;     /* (ignored)                   */
  39.         char         nplanes;   /* Number of planes (ver 2.5=0)*/
  40.         unsigned     bplin;     /* Bytes per line              */
  41.         unsigned     palinfo;   /* Palette Info (1=col, 2=gray)*/
  42.         unsigned     shres;     /* Scanner resolution          */
  43.         unsigned     svres;     /*                             */
  44.         char         xtra[54];  /* Extra space (filler)        */
  45.        } PCXhdr;
  46.  
  47.  
  48. typedef struct{
  49.                int file;
  50.                BOOL PCXpalette;
  51.                PAL pal;
  52.                BYTE buffer[BUFSIZE];
  53.                WORD pos;
  54.                     PCXhdr hdr;
  55.                   }PCXStruct;
  56.   
  57. /************************************************************************\
  58.  *                                                                      *
  59.  * ROUTINE: int FAR PASCAL LibMain(HANDLE hModule, WORD wDataSeg,       *
  60.  *                                 WORD cbHeapSize, LPSTR lpszCmdLine)  *
  61.  * PURPOSE: DLL entry point.                                            *
  62.  *                                                                      *
  63. \************************************************************************/
  64. int FAR PASCAL LibMain(HANDLE hModule, WORD wDataSeg,
  65. WORD cbHeapSize, LPSTR lpszCmdLine)
  66. {
  67.     return 1;
  68. }
  69.   
  70. /************************************************************************\
  71.  *                                                                      *
  72.  * ROUTINE: int FAR PASCAL WEP(int bSystemExit)                         *
  73.  *                                                                      *
  74.  * PURPOSE: DLL exit procedure                                          *
  75.  *                                                                      *
  76. \************************************************************************/
  77. int FAR PASCAL WEP(int bSystemExit)
  78. {
  79.     return 1;
  80. }
  81.   
  82.   
  83. /************************************************************************\
  84.  *                                                                      *
  85.  * ROUTINE: WORD FAR PASCAL Magic(void)                                 *
  86.  *                                                                      *
  87.  * PURPOSE: Identification routine                                      *
  88.  * RETURNS: 'Magic number' SRC_MAGIC                                    *
  89.  *                                                                      *
  90. \************************************************************************/
  91. WORD FAR PASCAL Magic(void)
  92. {
  93.     return DST_MAGIC;
  94. }
  95.   
  96. /************************************************************************\
  97.  *                                                                      *
  98.  * ROUTINE: void FAR PASCAL GetDescription(LPSTR str)                   *
  99.  *                                                                      *
  100.  * PURPOSE: Sets format name                                            *
  101.  *                                                                      *
  102.  * PARAMETERS: LPSTR str - pointer for format name storage. The length  *
  103.  *             name must be less than 40!                               *
  104.  *                                                                      *
  105. \************************************************************************/
  106. void FAR PASCAL GetDescription(LPSTR str)
  107. {
  108.     lstrcpy(str,"ZSoft PaintBrush PCX");
  109. }
  110.   
  111. /************************************************************************\
  112.  *                                                                      *
  113.  * ROUTINE: void FAR PASCAL GetExtension(LPSTR str)                     *
  114.  *                                                                      *
  115.  * PURPOSE: Sets format file extension                                  *
  116.  *                                                                      *
  117.  * PARAMETERS: LPSTR str - pointer for format file extension.           *
  118.  *                                                                      *
  119. \************************************************************************/
  120. void FAR PASCAL GetExtension(LPSTR str)
  121. {
  122.     lstrcpy(str,"PCX");
  123. }
  124.   
  125. /************************************************************************\
  126.  *                                                                      *
  127.  * ROUTINE: DWORD FAR PASCAL GetFlags(void)                             *
  128.  *                                                                      *
  129.  * PURPOSE: Sets flag for converter capabilities                        *
  130.  *                                                                      *
  131.  * PARAMETERS: None                                                     *
  132.  *                                                                      *
  133.  * RETURNS: Flags                                                       *
  134.  *  Color info bits                                                     *
  135.  *  INFO_COLOR      // Image is colored                                 *
  136.  *  INFO_PALETTE    // Image is paletted                                *
  137.  *  INFO_NEGATIVE   // Image is negative                                *
  138.  *  File organization bits                                              *
  139.  *  INFO_TEMPFILE   // Only using temporary file                        *
  140.  *  INFO_COMPRESSED // Image is compressed                              *
  141.  *  INFO_FORWARD    // Up to down                                       *
  142.  *  INFO_BACKWARD   // Down to up                                       *
  143.  *  INFO_RANDOM     // Random access is allowed                         *
  144.  *  Row organization bits                                               *
  145.  *  INFO_PACKED     // (bps < 8) bits are shifted together              *
  146.  *  INFO_SEPARATE   // (bps !=8) bitplanes are separated                *
  147.  *                                                                      *
  148.  *  Bits for GetFlags()                                                 *
  149.  *  Destination capabilites bits                                        *
  150.  *  INFO_1BPS       // Accepts 1-bit data                               *
  151.  *  INFO_4BPS       // Accepts 4-bit data                               *
  152.  *  INFO_8BPS       // Accepts 8-bit data