summaryrefslogtreecommitdiffstats
path: root/tdefile-plugins/dds
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/dds
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/dds')
-rw-r--r--tdefile-plugins/dds/CMakeLists.txt35
-rw-r--r--tdefile-plugins/dds/Makefile.am22
-rw-r--r--tdefile-plugins/dds/tdefile_dds.cpp317
-rw-r--r--tdefile-plugins/dds/tdefile_dds.desktop53
-rw-r--r--tdefile-plugins/dds/tdefile_dds.h38
5 files changed, 465 insertions, 0 deletions
diff --git a/tdefile-plugins/dds/CMakeLists.txt b/tdefile-plugins/dds/CMakeLists.txt
new file mode 100644
index 00000000..eb367982
--- /dev/null
+++ b/tdefile-plugins/dds/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_dds.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
+
+
+#### tdefile_dds (module) ##########################
+
+tde_add_kpart( tdefile_dds AUTOMOC
+ SOURCES tdefile_dds.cpp
+ LINK tdeio-shared
+ DESTINATION ${PLUGIN_INSTALL_DIR}
+)
diff --git a/tdefile-plugins/dds/Makefile.am b/tdefile-plugins/dds/Makefile.am
new file mode 100644
index 00000000..ce77c9c3
--- /dev/null
+++ b/tdefile-plugins/dds/Makefile.am
@@ -0,0 +1,22 @@
+## Makefile.am for dds 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_dds.h
+
+kde_module_LTLIBRARIES = tdefile_dds.la
+
+tdefile_dds_la_SOURCES = tdefile_dds.cpp
+tdefile_dds_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+tdefile_dds_la_LIBADD = $(LIB_KSYCOCA)
+
+# let automoc handle all of the meta source files (moc)
+METASOURCES = AUTO
+
+messages: rc.cpp
+ $(XGETTEXT) tdefile_dds.cpp -o $(podir)/tdefile_dds.pot
+
+services_DATA = tdefile_dds.desktop
+servicesdir = $(kde_servicesdir)
diff --git a/tdefile-plugins/dds/tdefile_dds.cpp b/tdefile-plugins/dds/tdefile_dds.cpp
new file mode 100644
index 00000000..e49bf498
--- /dev/null
+++ b/tdefile-plugins/dds/tdefile_dds.cpp
@@ -0,0 +1,317 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2002 Ignacio Casta�o <castano@ludicon.com>
+ *
+ * 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_dds.h"
+
+#include <kprocess.h>
+#include <klocale.h>
+#include <kgenericfactory.h>
+#include <kstringvalidator.h>
+#include <kdebug.h>
+
+#include <tqdict.h>
+#include <tqvalidator.h>
+#include <tqcstring.h>
+#include <tqfile.h>
+#include <tqdatetime.h>
+
+
+typedef KGenericFactory<KDdsPlugin> DdsFactory;
+
+typedef TQ_UINT32 uint;
+typedef TQ_UINT16 ushort;
+typedef TQ_UINT8 uchar;
+
+namespace { // Private.
+
+#if !defined(MAKEFOURCC)
+# define MAKEFOURCC(ch0, ch1, ch2, ch3) \
+ (uint(uchar(ch0)) | (uint(uchar(ch1)) << 8) | \
+ (uint(uchar(ch2)) << 16) | (uint(uchar(ch3)) << 24 ))
+#endif
+
+ static const uint FOURCC_DDS = MAKEFOURCC('D', 'D', 'S', ' ');
+ static const uint FOURCC_DXT1 = MAKEFOURCC('D', 'X', 'T', '1');
+ static const uint FOURCC_DXT2 = MAKEFOURCC('D', 'X', 'T', '2');
+ static const uint FOURCC_DXT3 = MAKEFOURCC('D', 'X', 'T', '3');
+ static const uint FOURCC_DXT4 = MAKEFOURCC('D', 'X', 'T', '4');
+ static const uint FOURCC_DXT5 = MAKEFOURCC('D', 'X', 'T', '5');
+ static const uint FOURCC_RXGB = MAKEFOURCC('R', 'X', 'G', 'B');
+
+ static const uint DDSD_CAPS = 0x00000001l;
+ static const uint DDSD_PIXELFORMAT = 0x00001000l;
+ static const uint DDSD_WIDTH = 0x00000004l;
+ static const uint DDSD_HEIGHT = 0x00000002l;
+ static const uint DDSD_PITCH = 0x00000008l;
+
+ static const uint DDSCAPS_TEXTURE = 0x00001000l;
+ static const uint DDSCAPS2_VOLUME = 0x00200000l;
+ static const uint DDSCAPS2_CUBEMAP = 0x00000200l;
+
+ static const uint DDPF_RGB = 0x00000040l;
+ static const uint DDPF_FOURCC = 0x00000004l;
+ static const uint DDPF_ALPHAPIXELS = 0x00000001l;
+
+ enum DDSType {
+ DDS_A8R8G8B8 = 0,
+ DDS_A1R5G5B5 = 1,
+ DDS_A4R4G4B4 = 2,
+ DDS_R8G8B8 = 3,
+ DDS_R5G6B5 = 4,
+ DDS_DXT1 = 5,
+ DDS_DXT2 = 6,
+ DDS_DXT3 = 7,
+ DDS_DXT4 = 8,
+ DDS_DXT5 = 9,
+ DDS_RXGB = 10,
+ DDS_UNKNOWN
+ };
+
+
+ struct DDSPixelFormat {
+ uint size;
+ uint flags;
+ uint fourcc;
+ uint bitcount;
+ uint rmask;
+ uint gmask;
+ uint bmask;
+ uint amask;
+ };
+
+ TQDataStream & operator>> ( TQDataStream & s, DDSPixelFormat & pf )
+ {
+ s >> pf.size;
+ s >> pf.flags;
+ s >> pf.fourcc;
+ s >> pf.bitcount;
+ s >> pf.rmask;
+ s >> pf.gmask;
+ s >> pf.bmask;
+ s >> pf.amask;
+ return s;
+ }
+
+ struct DDSCaps {
+ uint caps1;
+ uint caps2;
+ uint caps3;
+ uint caps4;
+ };
+
+ TQDataStream & operator>> ( TQDataStream & s, DDSCaps & caps )
+ {
+ s >> caps.caps1;
+ s >> caps.caps2;
+ s >> caps.caps3;
+ s >> caps.caps4;
+ return s;
+ }
+
+ struct DDSHeader {
+ uint size;
+ uint flags;
+ uint height;
+ uint width;
+ uint pitch;
+ uint depth;
+ uint mipmapcount;
+ uint reserved[11];
+ DDSPixelFormat pf;
+ DDSCaps caps;
+ uint notused;
+ };
+
+ TQDataStream & operator>> ( TQDataStream & s, DDSHeader & header )
+ {
+ s >> header.size;
+ s >> header.flags;
+ s >> header.height;
+ s >> header.width;
+ s >> header.pitch;
+ s >> header.depth;
+ s >> header.mipmapcount;
+ for( int i = 0; i < 11; i++ ) {
+ s >> header.reserved[i];
+ }
+ s >> header.pf;
+ s >> header.caps;
+ s >> header.notused;
+ return s;
+ }
+
+ static bool IsValid( const DDSHeader & header )
+ {
+ if( header.size != 124 ) {
+ return false;
+ }
+ const uint required = (DDSD_WIDTH|DDSD_HEIGHT|DDSD_CAPS|DDSD_PIXELFORMAT);
+ if( (header.flags & required) != required ) {
+ return false;
+ }
+ if( header.pf.size != 32 ) {
+ return false;
+ }
+ if( !(header.caps.caps1 & DDSCAPS_TEXTURE) ) {
+ return false;
+ }
+ return true;
+ }
+
+} // namespace
+
+
+
+K_EXPORT_COMPONENT_FACTORY(tdefile_dds, DdsFactory( "tdefile_dds" ))
+
+// Constructor, init mime type info.
+KDdsPlugin::KDdsPlugin(TQObject *parent, const char *name, const TQStringList &args) :
+ KFilePlugin(parent, name, args)
+{
+ KFileMimeTypeInfo * info = addMimeTypeInfo( "image/x-dds" );
+
+ KFileMimeTypeInfo::GroupInfo * group = 0L;
+
+ group = addGroupInfo(info, "Technical", i18n("Technical Details"));
+
+ KFileMimeTypeInfo::ItemInfo * item;
+
+ item = addItemInfo(group, "Dimensions", i18n("Dimensions"), TQVariant::Size);
+ setHint(item, KFileMimeTypeInfo::Size);
+ setUnit(item, KFileMimeTypeInfo::Pixels);
+
+ item = addItemInfo(group, "Depth", i18n("Depth"), TQVariant::Int);
+ setUnit(item, KFileMimeTypeInfo::Pixels);
+
+ item = addItemInfo(group, "BitDepth", i18n("Bit Depth"), TQVariant::Int);
+ setUnit(item, KFileMimeTypeInfo::BitsPerPixel);
+
+ addItemInfo(group, "MipmapCount", i18n("Mipmap Count"), TQVariant::Int);
+
+ addItemInfo(group, "Type", i18n("Type"), TQVariant::String);
+ addItemInfo(group, "ColorMode", i18n("Color Mode"), TQVariant::String);
+ addItemInfo(group, "Compression", i18n("Compression"), TQVariant::String);
+}
+
+// Read mime type info.
+bool KDdsPlugin::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 s(&file);
+ s.setByteOrder(TQDataStream::LittleEndian);
+
+ // Validate header.
+ uint fourcc;
+ s >> fourcc;
+ if( fourcc != FOURCC_DDS ) {
+ kdDebug(7034) << TQFile::encodeName(info.path()).data() << " is not a DDS file." << endl;
+ return false;
+ }
+
+ // Read image header.
+ DDSHeader header;
+ s >> header;
+
+ // Check image file format.
+ if( s.atEnd() || !IsValid( header ) ) {
+ kdDebug(7034) << TQFile::encodeName(info.path()).data() << " is not a valid DDS file." << endl;
+ return false;
+ }
+
+ // Set file info.
+ KFileMetaInfoGroup group = appendGroup(info, "Technical");
+ appendItem(group, "Dimensions", TQSize(header.width, header.height));
+ appendItem(group, "MipmapCount", header.mipmapcount);
+
+ // Set file type.
+ if( header.caps.caps2 & DDSCAPS2_CUBEMAP ) {
+ appendItem(group, "Type", i18n("Cube Map Texture"));
+ }
+ else if( header.caps.caps2 & DDSCAPS2_VOLUME ) {
+ appendItem(group, "Type", i18n("Volume Texture"));
+ appendItem(group, "Depth", header.depth);
+ }
+ else {
+ appendItem(group, "Type", i18n("2D Texture"));
+ }
+
+ // Set file color depth and compression.
+ if( header.pf.flags & DDPF_RGB ) {
+ appendItem(group, "BitDepth", header.pf.bitcount);
+ appendItem(group, "Compression", i18n("Uncompressed"));
+ if( header.pf.flags & DDPF_ALPHAPIXELS ) {
+ appendItem(group, "ColorMode", "RGB/Alpha");
+ }
+ else {
+ appendItem(group, "ColorMode", "RGB");
+ }
+ }
+ else if( header.pf.flags & DDPF_FOURCC ) {
+ switch( header.pf.fourcc ) {
+ case FOURCC_DXT1:
+ appendItem(group, "BitDepth", 4);
+ appendItem(group, "Compression", "DXT1");
+ appendItem(group, "ColorMode", "RGB");
+ break;
+ case FOURCC_DXT2:
+ appendItem(group, "BitDepth", 16);
+ appendItem(group, "Compression", "DXT2");
+ appendItem(group, "ColorMode", "RGB/Alpha");
+ break;
+ case FOURCC_DXT3:
+ appendItem(group, "BitDepth", 16);
+ appendItem(group, "Compression", "DXT3");
+ appendItem(group, "ColorMode", "RGB/Alpha");
+ break;
+ case FOURCC_DXT4:
+ appendItem(group, "BitDepth", 16);
+ appendItem(group, "Compression", "DXT4");
+ appendItem(group, "ColorMode", "RGB/Alpha");
+ break;
+ case FOURCC_DXT5:
+ appendItem(group, "BitDepth", 16);
+ appendItem(group, "Compression", "DXT5");
+ appendItem(group, "ColorMode", "RGB/Alpha");
+ break;
+ case FOURCC_RXGB:
+ appendItem(group, "BitDepth", 16);
+ appendItem(group, "Compression", "RXGB");
+ appendItem(group, "ColorMode", "RGB");
+ break;
+ default:
+ appendItem(group, "Compression", "Unknown");
+ break;
+ }
+ }
+ else {
+ appendItem(group, "Compression", "Unknown");
+ }
+
+ return true;
+}
+
+#include "tdefile_dds.moc"
+
diff --git a/tdefile-plugins/dds/tdefile_dds.desktop b/tdefile-plugins/dds/tdefile_dds.desktop
new file mode 100644
index 00000000..c98f0181
--- /dev/null
+++ b/tdefile-plugins/dds/tdefile_dds.desktop
@@ -0,0 +1,53 @@
+[Desktop Entry]
+Type=Service
+Name=DirectDraw Surface Info
+Name[ca]=Informació de superfície DirectDraw
+Name[cs]=DirectDraw Surface info
+Name[da]=DirectDraw overflade-info
+Name[de]=DirectDraw Oberflächeninfo
+Name[el]=Πληροφορίες επιφάνειας DirectDraw
+Name[eo]=DirectDraw surfac-informo
+Name[es]=Información de la primera vista de DirectDraw
+Name[et]=DirectDraw Surface'i info
+Name[eu]=DirectDraw Surface informazioa
+Name[fa]=اطلاعات سطح DirectDraw
+Name[fi]=DirectDraw pintatieto
+Name[fr]=Informations de surface DirectDraw
+Name[ga]=Eolas faoi DirectDraw Surface
+Name[gl]=Información de Superficie de DirectDraw
+Name[he]=מיגע אודות משטח DirectDraw
+Name[hu]=DirectDraw felületinformáció
+Name[is]=DirectDraw yfirborðs upplýsingar
+Name[it]=Informazioni superficie DirectDraw
+Name[ja]=DDS (DirectDraw Surface) 情報
+Name[kk]=DirectDraw бедерінің мәлметі
+Name[km]=ព័ត៌មាន​ផ្ទៃ​ខាង​ក្រៅ​អំពី DirectDraw
+Name[lt]=DirectDraw Surface informacija
+Name[ms]=Maklumat Permukaan LukisTerus
+Name[nb]=DirectDraw Overflate info
+Name[nds]="DirectDraw"-Böversietinfo
+Name[ne]=प्रत्यक्ष रेखाचित्र सतह सूचना
+Name[nl]=DirectDraw Surface-info
+Name[nn]=DirectDraw-overflateinfo
+Name[pl]=Informacja o powierzchni DirectDraw
+Name[pt]=Informação de Superfície DirectDraw
+Name[pt_BR]=Informações Sobre Superfícies Direct Draw
+Name[ro]=Informaţii Suprafaţă DirectDraw
+Name[ru]=Сведения о поверхности DirectDraw
+Name[sk]=DirectDraw informácie o povrchu
+Name[sl]=Podatki o površini DirectDraw
+Name[sr]=Информације о DirectDraw површини
+Name[sr@Latn]=Informacije o DirectDraw površini
+Name[sv]=Directdraw ytinformation
+Name[ta]=நேரடி மேற்பரப்பு தகவல்
+Name[th]=ข้อมูลแฟ้มพื้นผิว DirectDraw
+Name[tr]=DirectDraw Yüzey Bilgisi
+Name[uk]=Інформація про поверхню DirectDraw
+Name[zh_CN]=DirectDraw 表面信息
+Name[zh_HK]=DirectDraw 表面資訊
+Name[zh_TW]=DirectDraw Surface 資訊
+ServiceTypes=KFilePlugin
+X-TDE-Library=tdefile_dds
+MimeType=image/x-dds
+PreferredGroups=Technical
+PreferredItems=Dimensions,Depth,BitDepth,Type,ColorMode,Compression
diff --git a/tdefile-plugins/dds/tdefile_dds.h b/tdefile-plugins/dds/tdefile_dds.h
new file mode 100644
index 00000000..464ed6fd
--- /dev/null
+++ b/tdefile-plugins/dds/tdefile_dds.h
@@ -0,0 +1,38 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2002 Ignacio Castao <castano@ludicon.com>
+ *
+ * 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_DDS_H__
+#define __KFILE_DDS_H__
+
+#include <tdefilemetainfo.h>
+
+class TQStringList;
+
+class KDdsPlugin: public KFilePlugin
+{
+ Q_OBJECT
+
+
+public:
+ KDdsPlugin( TQObject *parent, const char *name, const TQStringList& args );
+
+ virtual bool readInfo( KFileMetaInfo& info, uint what);
+};
+
+#endif