summaryrefslogtreecommitdiffstats
path: root/tdefile-plugins/rgb
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-27 01:03:37 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-27 01:03:37 -0600
commit2e25fa39cd67cca2472d3eabdb478feb517d72a5 (patch)
tree63725962f632d152cbf20709191d39f6fc865966 /tdefile-plugins/rgb
parent190d88dfc662f3fc466c9d1f53acbbea65f33c49 (diff)
downloadtdegraphics-2e25fa39cd67cca2472d3eabdb478feb517d72a5.tar.gz
tdegraphics-2e25fa39cd67cca2472d3eabdb478feb517d72a5.zip
Rename a number of libraries and executables to avoid conflicts with KDE4
Diffstat (limited to 'tdefile-plugins/rgb')
-rw-r--r--tdefile-plugins/rgb/CMakeLists.txt35
-rw-r--r--tdefile-plugins/rgb/Makefile.am22
-rw-r--r--tdefile-plugins/rgb/tdefile_rgb.cpp208
-rw-r--r--tdefile-plugins/rgb/tdefile_rgb.desktop61
-rw-r--r--tdefile-plugins/rgb/tdefile_rgb.h42
5 files changed, 368 insertions, 0 deletions
diff --git a/tdefile-plugins/rgb/CMakeLists.txt b/tdefile-plugins/rgb/CMakeLists.txt
new file mode 100644
index 00000000..7596f2cb
--- /dev/null
+++ b/tdefile-plugins/rgb/CMakeLists.txt
@@ -0,0 +1,35 @@
+#################################################
+#
+# (C) 2010-2011 Calvin Morrison
+# mutantturkey@gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}
+ ${TDE_INCLUDE_DIR}
+ ${TQT_INCLUDE_DIRS}
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+)
+
+
+#### other data #################################
+
+install( FILES tdefile_rgb.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
+
+
+#### tdefile_rgb (module) #########################
+
+tde_add_kpart( tdefile_rgb AUTOMOC
+ SOURCES tdefile_rgb.cpp
+ LINK tdeio-shared
+ DESTINATION ${PLUGIN_INSTALL_DIR}
+)
diff --git a/tdefile-plugins/rgb/Makefile.am b/tdefile-plugins/rgb/Makefile.am
new file mode 100644
index 00000000..aab98d29
--- /dev/null
+++ b/tdefile-plugins/rgb/Makefile.am
@@ -0,0 +1,22 @@
+## Makefile.am for rgb file meta info plugin
+
+# set the include path for X, qt and KDE
+INCLUDES = $(all_includes)
+
+# these are the headers for your project
+noinst_HEADERS = tdefile_rgb.h
+
+kde_module_LTLIBRARIES = tdefile_rgb.la
+
+tdefile_rgb_la_SOURCES = tdefile_rgb.cpp
+tdefile_rgb_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+tdefile_rgb_la_LIBADD = $(LIB_KSYCOCA)
+
+# let automoc handle all of the meta source files (moc)
+METASOURCES = AUTO
+
+messages: rc.cpp
+ $(XGETTEXT) tdefile_rgb.cpp -o $(podir)/tdefile_rgb.pot
+
+services_DATA = tdefile_rgb.desktop
+servicesdir = $(kde_servicesdir)
diff --git a/tdefile-plugins/rgb/tdefile_rgb.cpp b/tdefile-plugins/rgb/tdefile_rgb.cpp
new file mode 100644
index 00000000..e503e438
--- /dev/null
+++ b/tdefile-plugins/rgb/tdefile_rgb.cpp
@@ -0,0 +1,208 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2004 Melchior FRANZ <mfranz@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 <config.h>
+#include "tdefile_rgb.h"
+
+#include <tqfile.h>
+#include <tqvalidator.h>
+
+#include <kdebug.h>
+#include <kgenericfactory.h>
+
+
+typedef KGenericFactory<KRgbPlugin> RgbFactory;
+
+K_EXPORT_COMPONENT_FACTORY(tdefile_rgb, RgbFactory("tdefile_rgb"))
+
+
+KRgbPlugin::KRgbPlugin(TQObject *parent, const char *name, const TQStringList &args) :
+ KFilePlugin(parent, name, args)
+{
+ KFileMimeTypeInfo* info = addMimeTypeInfo("image/x-rgb");
+
+ KFileMimeTypeInfo::GroupInfo* group = 0;
+ KFileMimeTypeInfo::ItemInfo* item;
+
+
+ group = addGroupInfo(info, "Comment", i18n("Comment"));
+
+ item = addItemInfo(group, "ImageName", i18n("Name"), TQVariant::String);
+ setAttributes(item, KFileMimeTypeInfo::Modifiable);
+ setHint(item, KFileMimeTypeInfo::Description);
+
+
+ group = addGroupInfo(info, "Technical", i18n("Technical Details"));
+
+ item = addItemInfo(group, "Dimensions", i18n("Dimensions"), TQVariant::Size);
+ setHint(item, KFileMimeTypeInfo::Size);
+ setUnit(item, KFileMimeTypeInfo::Pixels);
+
+ item = addItemInfo(group, "BitDepth", i18n("Bit Depth"), TQVariant::Int);
+ setUnit(item, KFileMimeTypeInfo::BitsPerPixel);
+
+ item = addItemInfo(group, "ColorMode", i18n("Color Mode"), TQVariant::String);
+ item = addItemInfo(group, "Compression", i18n("Compression"), TQVariant::String);
+ item = addItemInfo(group, "SharedRows",
+ i18n("percentage of avoided vertical redundancy (the higher the better)",
+ "Shared Rows"), TQVariant::String);
+
+}
+
+
+bool KRgbPlugin::readInfo(KFileMetaInfo& info, uint /*what*/)
+{
+ TQFile file(info.path());
+
+ if (!file.open(IO_ReadOnly)) {
+ kdDebug(7034) << "Couldn't open " << TQFile::encodeName(info.path()).data() << endl;
+ return false;
+ }
+
+ TQDataStream dstream(&file);
+
+ TQ_UINT16 magic;
+ TQ_UINT8 storage;
+ TQ_UINT8 bpc;
+ TQ_UINT16 dimension;
+ TQ_UINT16 xsize;
+ TQ_UINT16 ysize;
+ TQ_UINT16 zsize;
+ TQ_UINT32 pixmin;
+ TQ_UINT32 pixmax;
+ TQ_UINT32 dummy;
+ char imagename[80];
+ TQ_UINT32 colormap;
+
+ dstream >> magic;
+ dstream >> storage;
+ dstream >> bpc;
+ dstream >> dimension;
+ dstream >> xsize;
+ dstream >> ysize;
+ dstream >> zsize;
+ dstream >> pixmin;
+ dstream >> pixmax;
+ dstream >> dummy;
+ dstream.readRawBytes(imagename, 80);
+ imagename[79] = '\0';
+ dstream >> colormap;
+ TQ_UINT8 u8;
+ for (uint i = 0; i < 404; i++)
+ dstream >> u8;
+
+ if (magic != 474)
+ return false;
+
+ KFileMetaInfoGroup group;
+
+ group = appendGroup(info, "Technical");
+
+ if (dimension == 1)
+ ysize = 1;
+ appendItem(group, "Dimensions", TQSize(xsize, ysize));
+ appendItem(group, "BitDepth", zsize * 8 * bpc);
+
+ if (zsize == 1)
+ appendItem(group, "ColorMode", i18n("Grayscale"));
+ else if (zsize == 2)
+ appendItem(group, "ColorMode", i18n("Grayscale/Alpha"));
+ else if (zsize == 3)
+ appendItem(group, "ColorMode", i18n("RGB"));
+ else if (zsize == 4)
+ appendItem(group, "ColorMode", i18n("RGB/Alpha"));
+
+ if (!storage)
+ appendItem(group, "Compression", i18n("Uncompressed"));
+ else if (storage == 1) {
+ long compressed = file.size() - 512;
+ long verbatim = xsize * ysize * zsize;
+ appendItem(group, "Compression", i18n("Runlength Encoded")
+ + TQString(", %1%").arg(compressed * 100.0 / verbatim, 0, 'f', 1));
+
+ long k;
+ TQ_UINT32 offs;
+ TQMap<TQ_UINT32, uint> map;
+ TQMap<TQ_UINT32, uint>::Iterator it;
+ TQMap<TQ_UINT32, uint>::Iterator end = map.end();
+ for (k = 0; k < (ysize * zsize); k++) {
+ dstream >> offs;
+ if ((it = map.find(offs)) != end)
+ map.replace(offs, it.data() + 1);
+ else
+ map[offs] = 0;
+ }
+ for (k = 0, it = map.begin(); it != end; ++it)
+ k += it.data();
+
+ if (k)
+ appendItem(group, "SharedRows", TQString("%1%").arg(k * 100.0
+ / (ysize * zsize), 0, 'f', 1));
+ else
+ appendItem(group, "SharedRows", i18n("None"));
+ } else
+ appendItem(group, "Compression", i18n("Unknown"));
+
+
+ group = appendGroup(info, "Comment");
+ appendItem(group, "ImageName", imagename);
+
+ file.close();
+ return true;
+}
+
+
+bool KRgbPlugin::writeInfo(const KFileMetaInfo& info) const
+{
+ TQFile file(info.path());
+
+ if (!file.open(IO_WriteOnly|IO_Raw)) {
+ kdDebug(7034) << "couldn't open " << TQFile::encodeName(info.path()).data() << endl;
+ return false;
+ }
+
+ if (!file.at(24)) {
+ kdDebug(7034) << "couldn't set offset" << endl;
+ return false;
+ }
+
+ TQDataStream dstream(&file);
+ TQString s = info["Comment"]["ImageName"].value().toString();
+ s.truncate(79);
+
+ unsigned i;
+ for (i = 0; i < s.length(); i++)
+ dstream << TQ_UINT8(s.latin1()[i]);
+ for (; i < 80; i++)
+ dstream << TQ_UINT8(0);
+
+ file.close();
+ return true;
+}
+
+
+// restrict to 79 ASCII characters
+TQValidator* KRgbPlugin::createValidator(const TQString&, const TQString &,
+ const TQString &, TQObject* parent, const char* name) const
+{
+ return new TQRegExpValidator(TQRegExp("[\x0020-\x007E]{79}"), parent, name);
+}
+
+
+#include "tdefile_rgb.moc"
diff --git a/tdefile-plugins/rgb/tdefile_rgb.desktop b/tdefile-plugins/rgb/tdefile_rgb.desktop
new file mode 100644
index 00000000..9edecac8
--- /dev/null
+++ b/tdefile-plugins/rgb/tdefile_rgb.desktop
@@ -0,0 +1,61 @@
+[Desktop Entry]
+Type=Service
+Name=SGI Image (RGB)
+Name[br]=Skeudenn SGI (RGB)
+Name[bs]=SGI slika (RGB)
+Name[ca]=Imatge SGI (RGB)
+Name[cs]=SGI obrázek (RGB)
+Name[cy]=Delwedd SGI (RGB)
+Name[da]=SGI-billede (RGB)
+Name[de]=SGI-Bild (RGB)
+Name[el]=Εικόνα SGI (RGB)
+Name[es]=Imagen SGI (RGB)
+Name[et]=SGI pildifail (RGB)
+Name[eu]=SGI irudia RGB)
+Name[fa]=تصویر SGI (RGB)
+Name[fi]=SGI-kuva (RGB)
+Name[fr]=Image SGI (RVB)
+Name[ga]=Íomhá SGI (RGB)
+Name[gl]=Imaxe SGI (RGB)
+Name[he]=תמונת SGI (RGB)
+Name[hr]=SGI slika (RGB)
+Name[hu]=SGI-kép (RGB)
+Name[is]=SGI mynd (TGB)
+Name[it]=Immagine SGI (RGB)
+Name[ja]=SGI 画像 (RGB)
+Name[kk]=SGI кескіні (RGB)
+Name[km]=រូបភាព SGI (RGB)
+Name[lt]=SGI paveiksliukas (RGB)
+Name[ms]=Imej SGI (RGB)
+Name[nb]=Bildeindeks
+Name[nds]=SGI-Bild (RGB)
+Name[ne]=SGI छवि (RGB)
+Name[nl]=SGI-afbeelding (RGB)
+Name[nn]=SGI-bilete (RGB)
+Name[pl]=Obrazek SGI (RGB)
+Name[pt]=Imagem SGI (RGB)
+Name[pt_BR]=Imagem SGI (RGB)
+Name[ro]=Imagine SGI (RGB)
+Name[ru]=Изображение SGI (RGB)
+Name[rw]=SGI Ishusho (RGB)
+Name[se]=SGI-govva (RGB)
+Name[sk]=SGI obrázok (RGB)
+Name[sl]=Slika SGI (RGB)
+Name[sr]=SGI слика (RGB)
+Name[sr@Latn]=SGI slika (RGB)
+Name[sv]=SGI-bild (RGB)
+Name[ta]=எஸ்ஜிஐ படிமம் (RGB)
+Name[tg]=Тасвироти SGI (RGB)
+Name[th]=ภาพ SGI (RGB)
+Name[tr]=SGI Resmi(KYM)
+Name[uk]=Зображення SGI (RGB)
+Name[uz]=SGI-rasm (RGB)
+Name[uz@cyrillic]=SGI-расм (RGB)
+Name[zh_CN]=SGI 图像(RGB)
+Name[zh_HK]=SGI 圖像 (RGB)
+Name[zh_TW]=SGI 影像(RGB)
+ServiceTypes=KFilePlugin
+X-TDE-Library=tdefile_rgb
+MimeType=image/x-rgb
+PreferredGroups=Comment,Technical
+PreferredItems=Dimensions,BitDepth,ColorMode,Compression,SharedRows,ImageName
diff --git a/tdefile-plugins/rgb/tdefile_rgb.h b/tdefile-plugins/rgb/tdefile_rgb.h
new file mode 100644
index 00000000..6a4e0ae2
--- /dev/null
+++ b/tdefile-plugins/rgb/tdefile_rgb.h
@@ -0,0 +1,42 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2004 Melcrhio FRANZ <mfranz@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_RGB_H__
+#define __KFILE_RGB_H__
+
+#include <tdefilemetainfo.h>
+
+class TQStringList;
+
+class KRgbPlugin : public KFilePlugin
+{
+ Q_OBJECT
+
+
+public:
+ KRgbPlugin(TQObject *parent, const char *name, const TQStringList& args);
+ virtual bool readInfo(KFileMetaInfo& info, uint what);
+ virtual bool writeInfo(const KFileMetaInfo& info) const;
+ virtual TQValidator* createValidator(const TQString& mimetype,
+ const TQString &group, const TQString &key,
+ TQObject* parent, const char* name) const;
+
+};
+
+#endif