1 | /* This file is part of the KDE project |
2 | Copyright (C) 2002-2003 Nadeem Hasan <nhasan@kde.org> |
3 | |
4 | This program is free software; you can redistribute it and/or |
5 | modify it under the terms of the Lesser GNU General Public |
6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. |
8 | */ |
9 | |
10 | #ifndef PCX_H |
11 | #define PCX_H |
12 | |
13 | |
14 | #include <kdemacros.h> |
15 | #include <QtGui/QImageIOPlugin> |
16 | #include <QtCore/QDataStream> |
17 | #include <QtGui/QColor> |
18 | |
19 | class PCXHandler : public QImageIOHandler |
20 | { |
21 | public: |
22 | PCXHandler(); |
23 | |
24 | bool canRead() const; |
25 | bool read(QImage *image); |
26 | bool write(const QImage &image); |
27 | |
28 | QByteArray name() const; |
29 | |
30 | static bool canRead(QIODevice *device); |
31 | }; |
32 | |
33 | class RGB |
34 | { |
35 | public: |
36 | quint8 r; |
37 | quint8 g; |
38 | quint8 b; |
39 | |
40 | static RGB from( const QRgb &color) |
41 | { |
42 | RGB c; |
43 | c.r = qRed( color ); |
44 | c.g = qGreen( color ); |
45 | c.b = qBlue( color ); |
46 | return c; |
47 | } |
48 | |
49 | } KDE_PACKED; |
50 | |
51 | class Palette |
52 | { |
53 | public: |
54 | void setColor( int i, const QRgb color ) |
55 | { |
56 | RGB &c = rgb[ i ]; |
57 | c.r = qRed( color ); |
58 | c.g = qGreen( color ); |
59 | c.b = qBlue( color ); |
60 | } |
61 | |
62 | QRgb color( int i ) const |
63 | { |
64 | return qRgb( rgb[ i ].r, rgb[ i ].g, rgb[ i ].b ); |
65 | } |
66 | |
67 | class RGB rgb[ 16 ]; |
68 | } KDE_PACKED; |
69 | |
70 | class |
71 | { |
72 | public: |
73 | (); |
74 | |
75 | inline int () const { return ( XMax-XMin ) + 1; } |
76 | inline int () const { return ( YMax-YMin ) + 1; } |
77 | inline bool () const { return ( Encoding==1 ); } |
78 | |
79 | quint8 ; // Constant Flag, 10 = ZSoft .pcx |
80 | quint8 ; // Version information· |
81 | // 0 = Version 2.5 of PC Paintbrush· |
82 | // 2 = Version 2.8 w/palette information· |
83 | // 3 = Version 2.8 w/o palette information· |
84 | // 4 = PC Paintbrush for Windows(Plus for |
85 | // Windows uses Ver 5)· |
86 | // 5 = Version 3.0 and > of PC Paintbrush |
87 | // and PC Paintbrush +, includes |
88 | // Publisher's Paintbrush . Includes |
89 | // 24-bit .PCX files· |
90 | quint8 ; // 1 = .PCX run length encoding |
91 | quint8 ; // Number of bits to represent a pixel |
92 | // (per Plane) - 1, 2, 4, or 8· |
93 | quint16 ; |
94 | quint16 ; |
95 | quint16 ; |
96 | quint16 ; |
97 | quint16 ; |
98 | quint16 ; |
99 | Palette ; |
100 | quint8 ; // Should be set to 0. |
101 | quint8 ; // Number of color planes |
102 | quint16 ; // Number of bytes to allocate for a scanline |
103 | // plane. MUST be an EVEN number. Do NOT |
104 | // calculate from Xmax-Xmin.· |
105 | quint16 ; // How to interpret palette- 1 = Color/BW, |
106 | // 2 = Grayscale ( ignored in PB IV/ IV + )· |
107 | quint16 ; // Horizontal screen size in pixels. New field |
108 | // found only in PB IV/IV Plus |
109 | quint16 ; // Vertical screen size in pixels. New field |
110 | // found only in PB IV/IV Plus |
111 | } KDE_PACKED; |
112 | |
113 | #endif // PCX_H |
114 | |
115 | /* vim: et sw=2 ts=2 |
116 | */ |
117 | |