KImgIO
pcx.h
Go to the documentation of this file.00001 /* This file is part of the KDE project 00002 Copyright (C) 2002-2003 Nadeem Hasan <nhasan@kde.org> 00003 00004 This program is free software; you can redistribute it and/or 00005 modify it under the terms of the Lesser GNU General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 */ 00009 00010 #ifndef PCX_H 00011 #define PCX_H 00012 00013 00014 #include <kdemacros.h> 00015 #include <QtGui/QImageIOPlugin> 00016 #include <QtCore/QDataStream> 00017 #include <QtGui/QColor> 00018 00019 class PCXHandler : public QImageIOHandler 00020 { 00021 public: 00022 PCXHandler(); 00023 00024 bool canRead() const; 00025 bool read(QImage *image); 00026 bool write(const QImage &image); 00027 00028 QByteArray name() const; 00029 00030 static bool canRead(QIODevice *device); 00031 }; 00032 00033 class RGB 00034 { 00035 public: 00036 quint8 r; 00037 quint8 g; 00038 quint8 b; 00039 00040 static RGB from( const QRgb &color) 00041 { 00042 RGB c; 00043 c.r = qRed( color ); 00044 c.g = qGreen( color ); 00045 c.b = qBlue( color ); 00046 return c; 00047 } 00048 00049 } KDE_PACKED; 00050 00051 class Palette 00052 { 00053 public: 00054 void setColor( int i, const QRgb color ) 00055 { 00056 RGB &c = rgb[ i ]; 00057 c.r = qRed( color ); 00058 c.g = qGreen( color ); 00059 c.b = qBlue( color ); 00060 } 00061 00062 QRgb color( int i ) const 00063 { 00064 return qRgb( rgb[ i ].r, rgb[ i ].g, rgb[ i ].b ); 00065 } 00066 00067 class RGB rgb[ 16 ]; 00068 } KDE_PACKED; 00069 00070 class PCXHEADER 00071 { 00072 public: 00073 PCXHEADER(); 00074 00075 inline int width() const { return ( XMax-XMin ) + 1; } 00076 inline int height() const { return ( YMax-YMin ) + 1; } 00077 inline bool isCompressed() const { return ( Encoding==1 ); } 00078 00079 quint8 Manufacturer; // Constant Flag, 10 = ZSoft .pcx 00080 quint8 Version; // Version information· 00081 // 0 = Version 2.5 of PC Paintbrush· 00082 // 2 = Version 2.8 w/palette information· 00083 // 3 = Version 2.8 w/o palette information· 00084 // 4 = PC Paintbrush for Windows(Plus for 00085 // Windows uses Ver 5)· 00086 // 5 = Version 3.0 and > of PC Paintbrush 00087 // and PC Paintbrush +, includes 00088 // Publisher's Paintbrush . Includes 00089 // 24-bit .PCX files· 00090 quint8 Encoding; // 1 = .PCX run length encoding 00091 quint8 Bpp; // Number of bits to represent a pixel 00092 // (per Plane) - 1, 2, 4, or 8· 00093 quint16 XMin; 00094 quint16 YMin; 00095 quint16 XMax; 00096 quint16 YMax; 00097 quint16 HDpi; 00098 quint16 YDpi; 00099 Palette ColorMap; 00100 quint8 Reserved; // Should be set to 0. 00101 quint8 NPlanes; // Number of color planes 00102 quint16 BytesPerLine; // Number of bytes to allocate for a scanline 00103 // plane. MUST be an EVEN number. Do NOT 00104 // calculate from Xmax-Xmin.· 00105 quint16 PaletteInfo; // How to interpret palette- 1 = Color/BW, 00106 // 2 = Grayscale ( ignored in PB IV/ IV + )· 00107 quint16 HScreenSize; // Horizontal screen size in pixels. New field 00108 // found only in PB IV/IV Plus 00109 quint16 VScreenSize; // Vertical screen size in pixels. New field 00110 // found only in PB IV/IV Plus 00111 } KDE_PACKED; 00112 00113 #endif // PCX_H 00114 00115 /* vim: et sw=2 ts=2 00116 */