summaryrefslogtreecommitdiffstats
path: root/kimgio/pcx.h
blob: 40f4f8e7396e54cbbb952dc67dcd6a6c8d02b8ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* This file is part of the KDE project
   Copyright (C) 2002-2003 Nadeem Hasan <[email protected]>

   This program is free software; you can redistribute it and/or
   modify it under the terms of the Lesser GNU General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.
*/

#ifndef PCX_H
#define PCX_H

#include <tqglobal.h>
#include <tqdatastream.h>
#include <tqcolor.h>

class TQImageIO;

extern "C"
{
  void kimgio_pcx_read( TQImageIO * );
  void kimgio_pcx_write( TQImageIO * );
}

class RGB
{
  public:
    RGB() { }

    RGB( const TQRgb color )
    {
      r = tqRed( color );
      g = tqGreen( color );
      b = tqBlue( color );
    }

    TQ_UINT8 r;
    TQ_UINT8 g;
    TQ_UINT8 b;
};

class Palette
{
  public:
    Palette() { }

    void setColor( int i, const TQRgb color )
    {
      rgb[ i ] = RGB( color );
    }

    TQRgb color( int i ) const
    {
      return tqRgb( rgb[ i ].r, rgb[ i ].g, rgb[ i ].b );
    }

    struct RGB rgb[ 16 ];
};

class PCXHEADER
{
  public:
    PCXHEADER();

    inline int width() const { return ( XMax-XMin ) + 1; }
    inline int height() const { return ( YMax-YMin ) + 1; }
    inline bool isCompressed() const { return ( Encoding==1 ); }

    TQ_UINT8  Manufacturer;    // Constant Flag, 10 = ZSoft .pcx
    TQ_UINT8  Version;         // Version information
                              // 0 = Version 2.5 of PC Paintbrush
                              // 2 = Version 2.8 w/palette information
                              // 3 = Version 2.8 w/o palette information
                              // 4 = PC Paintbrush for Windows(Plus for
                              //     Windows uses Ver 5)
                              // 5 = Version 3.0 and > of PC Paintbrush
                              //     and PC Paintbrush +, includes
                              //     Publisher's Paintbrush . Includes
                              //     24-bit .PCX files
    TQ_UINT8  Encoding;        // 1 = .PCX run length encoding
    TQ_UINT8  Bpp;             // Number of bits to represent a pixel
                              // (per Plane) - 1, 2, 4, or 8
    TQ_UINT16 XMin;
    TQ_UINT16 YMin;
    TQ_UINT16 XMax;
    TQ_UINT16 YMax;
    TQ_UINT16 HDpi;
    TQ_UINT16 YDpi;
    Palette  ColorMap;
    TQ_UINT8  Reserved;        // Should be set to 0.
    TQ_UINT8  NPlanes;         // Number of color planes
    TQ_UINT16 BytesPerLine;    // Number of bytes to allocate for a scanline
                              // plane.  MUST be an EVEN number.  Do NOT
                              // calculate from Xmax-Xmin.
    TQ_UINT16 PaletteInfo;     // How to interpret palette- 1 = Color/BW,
                              // 2 = Grayscale ( ignored in PB IV/ IV + )
    TQ_UINT16 HScreenSize;     // Horizontal screen size in pixels. New field
                              // found only in PB IV/IV Plus
    TQ_UINT16 VScreenSize;     // Vertical screen size in pixels. New field
                              // found only in PB IV/IV Plus
} TDE_PACKED;

#endif // PCX_H