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 #include <qglobal.h> 00014 #include <qdatastream.h> 00015 #include <qcolor.h> 00016 00017 class QImageIO; 00018 00019 extern "C" 00020 { 00021 void kimgio_pcx_read( QImageIO * ); 00022 void kimgio_pcx_write( QImageIO * ); 00023 } 00024 00025 class RGB 00026 { 00027 public: 00028 RGB() { } 00029 00030 RGB( const QRgb color ) 00031 { 00032 r = qRed( color ); 00033 g = qGreen( color ); 00034 b = qBlue( color ); 00035 } 00036 00037 Q_UINT8 r; 00038 Q_UINT8 g; 00039 Q_UINT8 b; 00040 }; 00041 00042 class Palette 00043 { 00044 public: 00045 Palette() { } 00046 00047 void setColor( int i, const QRgb color ) 00048 { 00049 rgb[ i ] = RGB( color ); 00050 } 00051 00052 QRgb color( int i ) const 00053 { 00054 return qRgb( rgb[ i ].r, rgb[ i ].g, rgb[ i ].b ); 00055 } 00056 00057 struct RGB rgb[ 16 ]; 00058 }; 00059 00060 class PCXHEADER 00061 { 00062 public: 00063 PCXHEADER(); 00064 00065 inline int width() const { return ( XMax-XMin ) + 1; } 00066 inline int height() const { return ( YMax-YMin ) + 1; } 00067 inline bool isCompressed() const { return ( Encoding==1 ); } 00068 00069 Q_UINT8 Manufacturer; // Constant Flag, 10 = ZSoft .pcx 00070 Q_UINT8 Version; // Version informationˇ 00071 // 0 = Version 2.5 of PC Paintbrushˇ 00072 // 2 = Version 2.8 w/palette informationˇ 00073 // 3 = Version 2.8 w/o palette informationˇ 00074 // 4 = PC Paintbrush for Windows(Plus for 00075 // Windows uses Ver 5)ˇ 00076 // 5 = Version 3.0 and > of PC Paintbrush 00077 // and PC Paintbrush +, includes 00078 // Publisher's Paintbrush . Includes 00079 // 24-bit .PCX filesˇ 00080 Q_UINT8 Encoding; // 1 = .PCX run length encoding 00081 Q_UINT8 Bpp; // Number of bits to represent a pixel 00082 // (per Plane) - 1, 2, 4, or 8ˇ 00083 Q_UINT16 XMin; 00084 Q_UINT16 YMin; 00085 Q_UINT16 XMax; 00086 Q_UINT16 YMax; 00087 Q_UINT16 HDpi; 00088 Q_UINT16 YDpi; 00089 Palette ColorMap; 00090 Q_UINT8 Reserved; // Should be set to 0. 00091 Q_UINT8 NPlanes; // Number of color planes 00092 Q_UINT16 BytesPerLine; // Number of bytes to allocate for a scanline 00093 // plane. MUST be an EVEN number. Do NOT 00094 // calculate from Xmax-Xmin.ˇ 00095 Q_UINT16 PaletteInfo; // How to interpret palette- 1 = Color/BW, 00096 // 2 = Grayscale ( ignored in PB IV/ IV + )ˇ 00097 Q_UINT16 HScreenSize; // Horizontal screen size in pixels. New field 00098 // found only in PB IV/IV Plus 00099 Q_UINT16 VScreenSize; // Vertical screen size in pixels. New field 00100 // found only in PB IV/IV Plus 00101 } KDE_PACKED; 00102 00103 #endif // PCX_H 00104 00105 /* vim: et sw=2 ts=2 00106 */