summaryrefslogtreecommitdiffstats
path: root/kfile-plugins/pcx
diff options
context:
space:
mode:
Diffstat (limited to 'kfile-plugins/pcx')
-rw-r--r--kfile-plugins/pcx/Makefile.am21
-rw-r--r--kfile-plugins/pcx/kfile_pcx.cpp122
-rw-r--r--kfile-plugins/pcx/kfile_pcx.desktop62
-rw-r--r--kfile-plugins/pcx/kfile_pcx.h88
4 files changed, 293 insertions, 0 deletions
diff --git a/kfile-plugins/pcx/Makefile.am b/kfile-plugins/pcx/Makefile.am
new file mode 100644
index 00000000..111b4c28
--- /dev/null
+++ b/kfile-plugins/pcx/Makefile.am
@@ -0,0 +1,21 @@
+## Makefile.am for PCX file meta info plugin
+
+# set the include path for X, qt and KDE
+INCLUDES = $(all_includes)
+
+noinst_HEADERS = kfile_pcx.h
+
+kde_module_LTLIBRARIES = kfile_pcx.la
+
+kfile_pcx_la_SOURCES = kfile_pcx.cpp
+kfile_pcx_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+kfile_pcx_la_LIBADD = $(LIB_KIO) $(LIBTIFF)
+
+# let automoc handle all of the meta source files (moc)
+METASOURCES = AUTO
+
+messages:
+ $(XGETTEXT) *.cpp -o $(podir)/kfile_pcx.pot
+
+services_DATA = kfile_pcx.desktop
+servicesdir = $(kde_servicesdir)
diff --git a/kfile-plugins/pcx/kfile_pcx.cpp b/kfile-plugins/pcx/kfile_pcx.cpp
new file mode 100644
index 00000000..a7468a57
--- /dev/null
+++ b/kfile-plugins/pcx/kfile_pcx.cpp
@@ -0,0 +1,122 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2002 Nadeem Hasan <nhasan@kde.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "kfile_pcx.h"
+
+#include <kgenericfactory.h>
+#include <kdebug.h>
+
+#include <qdatastream.h>
+#include <qfile.h>
+
+typedef KGenericFactory<KPcxPlugin> PcxFactory;
+
+K_EXPORT_COMPONENT_FACTORY(kfile_pcx, PcxFactory("kfile_pcx"))
+
+QDataStream &operator>>( QDataStream &s, PALETTE &pal )
+{
+ for ( int i=0; i<16; ++i )
+ s >> pal.p[ i ].r >> pal.p[ i ].g >> pal.p[ i ].b;
+
+ return s;
+}
+
+QDataStream &operator>>( QDataStream &s, PCXHEADER &ph )
+{
+ s >> ph.Manufacturer;
+ s >> ph.Version;
+ s >> ph.Encoding;
+ s >> ph.Bpp;
+ s >> ph.XMin >> ph.YMin >> ph.XMax >> ph.YMax;
+ s >> ph.HDpi >> ph.YDpi;
+ s >> ph.Palette;
+ s >> ph.Reserved;
+ s >> ph.NPlanes;
+ s >> ph.BytesPerLine;
+ s >> ph.PaletteInfo;
+ s >> ph.HScreenSize;
+ s >> ph.VScreenSize;
+
+ return s;
+}
+
+KPcxPlugin::KPcxPlugin( QObject *parent, const char *name,
+ const QStringList &args ) : KFilePlugin( parent, name, args )
+{
+ kdDebug(7034) << "PCX file meta info plugin" << endl;
+ KFileMimeTypeInfo* info = addMimeTypeInfo( "image/x-pcx" );
+
+ KFileMimeTypeInfo::GroupInfo* group =
+ addGroupInfo( info, "General", i18n( "General" ) );
+
+ KFileMimeTypeInfo::ItemInfo* item;
+ item = addItemInfo( group, "Dimensions", i18n( "Dimensions" ),
+ QVariant::Size );
+ setHint( item, KFileMimeTypeInfo::Size );
+ setUnit( item, KFileMimeTypeInfo::Pixels );
+ item = addItemInfo( group, "BitDepth", i18n( "Bit Depth" ),
+ QVariant::Int );
+ setUnit( item, KFileMimeTypeInfo::BitsPerPixel );
+ item = addItemInfo( group, "Resolution", i18n( "Resolution" ),
+ QVariant::Size );
+ setUnit( item, KFileMimeTypeInfo::DotsPerInch );
+ item = addItemInfo( group, "Compression", i18n( "Compression" ),
+ QVariant::String );
+}
+
+bool KPcxPlugin::readInfo( KFileMetaInfo& info, uint )
+{
+ if ( info.path().isEmpty() )
+ return false;
+
+ struct PCXHEADER header;
+
+ QFile f( info.path() );
+ if ( !f.open( IO_ReadOnly ) )
+ return false;
+
+ QDataStream s( &f );
+ s.setByteOrder( QDataStream::LittleEndian );
+
+ s >> header;
+
+ int w = ( header.XMax-header.XMin ) + 1;
+ int h = ( header.YMax-header.YMin ) + 1;
+ int bpp = header.Bpp*header.NPlanes;
+
+ KFileMetaInfoGroup group = appendGroup( info, "General" );
+
+ appendItem( group, "Dimensions", QSize( w, h ) );
+ appendItem( group, "BitDepth", bpp );
+ appendItem( group, "Resolution", QSize( header.HDpi, header.YDpi ) );
+ if ( header.Encoding == 1 )
+ appendItem( group, "Compression", i18n( "Yes (RLE)" ) );
+ else
+ appendItem( group, "Compression", i18n( "None" ) );
+
+ f.close();
+
+ return true;
+}
+
+#include "kfile_pcx.moc"
+
+/* vim: et sw=2 ts=2
+*/
+
diff --git a/kfile-plugins/pcx/kfile_pcx.desktop b/kfile-plugins/pcx/kfile_pcx.desktop
new file mode 100644
index 00000000..9a3f2090
--- /dev/null
+++ b/kfile-plugins/pcx/kfile_pcx.desktop
@@ -0,0 +1,62 @@
+[Desktop Entry]
+Type=Service
+Name=PCX File Meta Info
+Name[ar]=معلومات ملف PCX
+Name[br]=Meta-titouroù ar restr PCX
+Name[bs]=PCX meta-podaci
+Name[ca]=Metainformació de fitxer PCX
+Name[cs]=Metainformace obrázku typu PCX
+Name[cy]=Meta-wybodaeth Ffeil PCX
+Name[da]=PCX Fil-meta-info
+Name[de]=PCX Metainformation
+Name[el]=Μετα-πληροφορίες αρχείου PCX
+Name[eo]=PCX-dosiera metainformo
+Name[es]=Info meta de archivos PCX
+Name[et]=PCX faili metainfo
+Name[eu]=PCX fitxategi meta info
+Name[fa]=فرااطلاعات پروندۀ PCX
+Name[fi]=PCX-tiedoston metatiedot
+Name[fr]=Méta Informations sur les fichiers PCX
+Name[gl]=Inf. metaficheiro PCX
+Name[he]=מידע PCX
+Name[hi]=PCX फ़ाइल मेटा जानकारी
+Name[hu]=PCX-jellemzők
+Name[is]=PCX File Meta upplýsingar
+Name[it]=Informazioni PCX
+Name[ja]=PCX ファイルメタ情報
+Name[kk]=PCX файлдың мета деректері
+Name[km]=ព័ត៌មាន​មេតា​របស់​ឯកសារ PCX
+Name[lt]=PCX bylos meta informacija
+Name[ms]=Maklumat Meta Fail PCX
+Name[nb]=PCX-filmetainfo
+Name[nds]=PCX-Metainfo
+Name[ne]=PCX फाइल मेटा सूचना
+Name[nl]=PCX meta-info
+Name[nn]=PCX-filmetainfo
+Name[pl]=Informacja o pliku PCX
+Name[pt]=Meta-Informação do Ficheiro PCX
+Name[pt_BR]=Informação sobre Meta Arquivo PCX
+Name[ro]=Metainformaţii PCX
+Name[ru]=Информация о метафайле PCX
+Name[se]=PCX-filla metadieđut
+Name[sk]=Meta-info o súbore PCX
+Name[sl]=Meta podatki o PCX
+Name[sr]=Мета информације PCX фајла
+Name[sr@Latn]=Meta informacije PCX fajla
+Name[sv]=Metainformation om PCX-fil
+Name[ta]=PCX File Meta தகவல்
+Name[tg]=Иттилоот оиди метафайли PCX
+Name[th]=ข้อมูลเมตาแฟ้ม PCX
+Name[tr]=PCX Dosya Bilgisi
+Name[uk]=Метаінформація про файл PCX
+Name[uz]=PCX-faylining meta-maʼlumoti
+Name[uz@cyrillic]=PCX-файлининг мета-маълумоти
+Name[wa]=Informåcion sol imådje PCX
+Name[zh_CN]=PCX 文件元信息
+Name[zh_HK]=PCX 檔案 Meta 資訊
+Name[zh_TW]=PCX 檔案 Meta 資訊
+ServiceTypes=KFilePlugin
+X-KDE-Library=kfile_pcx
+MimeType=image/x-pcx
+PreferredGroups=General
+PreferredItems=Dimensions,Resolution,BitDepth,Compression
diff --git a/kfile-plugins/pcx/kfile_pcx.h b/kfile-plugins/pcx/kfile_pcx.h
new file mode 100644
index 00000000..434f89a3
--- /dev/null
+++ b/kfile-plugins/pcx/kfile_pcx.h
@@ -0,0 +1,88 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2002 Nadeem Hasan <nhasan@kde.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef __KFILE_PCX_H_
+#define __KFILE_PCX_H_
+
+#include <kfilemetainfo.h>
+
+struct PALETTE
+{
+ struct
+ {
+ Q_UINT8 r;
+ Q_UINT8 g;
+ Q_UINT8 b;
+ } p[ 16 ];
+};
+
+struct PCXHEADER
+{
+ Q_UINT8 Manufacturer; // Constant Flag, 10 = ZSoft .pcx
+ Q_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
+ Q_UINT8 Encoding; // 1 = .PCX run length encoding
+ Q_UINT8 Bpp; // Number of bits to represent a pixel
+ // (per Plane) - 1, 2, 4, or 8
+ Q_UINT16 XMin;
+ Q_UINT16 YMin;
+ Q_UINT16 XMax;
+ Q_UINT16 YMax;
+ Q_UINT16 HDpi;
+ Q_UINT16 YDpi;
+ struct PALETTE Palette;
+ Q_UINT8 Reserved; // Should be set to 0.
+ Q_UINT8 NPlanes; // Number of color planes
+ Q_UINT16 BytesPerLine; // Number of bytes to allocate for a scanline
+ // plane. MUST be an EVEN number. Do NOT
+ // calculate from Xmax-Xmin.
+ Q_UINT16 PaletteInfo; // How to interpret palette- 1 = Color/BW,
+ // 2 = Grayscale ( ignored in PB IV/ IV + )
+ Q_UINT16 HScreenSize; // Horizontal screen size in pixels. New field
+ // found only in PB IV/IV Plus
+ Q_UINT16 VScreenSize; // Vertical screen size in pixels. New field
+ // found only in PB IV/IV Plus
+ Q_UINT8 Filler[ 54 ]; // Blank to fill out 128 byte header. Set all
+ // bytes to 0
+};
+
+class KPcxPlugin: public KFilePlugin
+{
+ Q_OBJECT
+
+public:
+ KPcxPlugin(QObject *parent, const char *name, const QStringList& args);
+ virtual bool readInfo(KFileMetaInfo& info, uint what);
+
+private:
+};
+
+#endif
+
+/* vim: et sw=2 ts=2
+*/
+