[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Krita import/export filter
From:       Boudewijn Rempt <boud () valdyas ! org>
Date:       2005-04-14 18:52:36
Message-ID: 200504142052.36793.boud () valdyas ! org
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


Melchior Franz reported he was ready to give up on Krita because he thought he 
couldn't export to any standard image format, and that showed me it was 
really necessary to change the way Krita handled import/export and bring it 
more in line with KOffice as a whole.

Previously, images could be imported and exported from the image menu, and the 
file/import & file/export items didn't go much beyond three versions of 
Krita's own file format.

I think I have fixed this now, but I had to add a .desktop file for export and 
do some other changes. Is it okay for me to check this in despite the freeze?
I've attached the relevant files, since I'm not sure I've done everything as 
it should be done and wouldn't mind someone vetting my work.

-- 
Boudewijn Rempt 
http://www.valdyas.org/fading/index.cgi

["krita_magick_export.desktop" (application/x-desktop)]
["magickexport.h" (text/x-c++hdr)]

/*
 *  Copyright (c) 2002 Patrick Julien <freak@codepimps.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; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  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; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
#if !defined MAGICKEXPORT_H_
#define MAGICKEXPORT_H_

#include <koFilter.h>

class MagickExport : public KoFilter {
	Q_OBJECT

public:
	MagickExport(KoFilter *parent, const char *name, const QStringList&);
	virtual ~MagickExport();

public:
	virtual KoFilter::ConversionStatus convert(const QCString& from, const QCString& to);
};

#endif // MAGICKEXPORT_H_


["krita_magick_import.desktop" (application/x-desktop)]
["magickexport.cpp" (text/x-c++src)]

/*
 *  Copyright (c) 2002 Patrick Julien <freak@codepimps.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; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  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; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
#include <magickexport.h>
#include <kgenericfactory.h>
#include <koDocument.h>
#include <koFilterChain.h>
#include <kis_doc.h>

typedef KGenericFactory<MagickExport, KoFilter> MagickExportFactory;
K_EXPORT_COMPONENT_FACTORY(libkritamagickexport, MagickExportFactory("kritamagickexport"))

MagickExport::MagickExport(KoFilter *, const char *, const QStringList&) : KoFilter()
{
}

MagickExport::~MagickExport()
{
}

KoFilter::ConversionStatus MagickExport::convert(const QCString& from, const QCString& to)
{
	kdDebug() << "magick export!\n";
	if (from != "application/x-krita")
		return KoFilter::NotImplemented;

	// XXX: Add dialog about flattening layers here

	KisDoc *output = dynamic_cast<KisDoc*>(m_chain -> inputDocument());
	QString outputFilename = m_chain -> outputFile();
	
	if (!output)
		return KoFilter::CreationError;
	
	return output -> exportImage(outputFilename) ? KoFilter::OK : KoFilter::BadMimeType;
}

#include <magickexport.moc>


["magickimport.cpp" (text/x-c++src)]

/*
 *  Copyright (c) 2002 Patrick Julien <freak@codepimps.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; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  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; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
#include <magickimport.h>
#include <kgenericfactory.h>
#include <koDocument.h>
#include <koFilterChain.h>
#include <kis_doc.h>

typedef KGenericFactory<MagickImport, KoFilter> MagickImportFactory;
K_EXPORT_COMPONENT_FACTORY(libkritamagickimport, MagickImportFactory("kritamagickimport"))

MagickImport::MagickImport(KoFilter *, const char *, const QStringList&) : KoFilter()
{
}

MagickImport::~MagickImport()
{
}

KoFilter::ConversionStatus MagickImport::convert(const QCString&, const QCString& to)
{
	kdDebug() << "Importing using MagickImport!\n";

	if (to != "application/x-krita")
		return KoFilter::BadMimeType;

	KisDoc *input = dynamic_cast<KisDoc*>(m_chain -> outputDocument());
	QString inputFilename = m_chain -> inputFile();
	
	if (!input)
		return KoFilter::CreationError;
	
	return input -> importImage(inputFilename) ? KoFilter::OK : KoFilter::BadMimeType;
}

#include <magickimport.moc>


["magickimport.h" (text/x-c++hdr)]

/*
 *  Copyright (c) 2002 Patrick Julien <freak@codepimps.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; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  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; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
#if !defined MAGICKIMPORT_H_
#define MAGICKIMPORT_H_

#include <koFilter.h>

class MagickImport : public KoFilter {
	Q_OBJECT

public:
	MagickImport(KoFilter *parent, const char *name, const QStringList&);
	virtual ~MagickImport();

public:
	virtual KoFilter::ConversionStatus convert(const QCString& from, const QCString& to);
};

#endif // MAGICKIMPORT_H_


["Makefile.am" (text/x-makefile)]

kde_module_LTLIBRARIES = libkritamagickimport.la libkritamagickexport.la

libkritamagickexport_la_LDFLAGS = $(KDE_PLUGIN)
libkritamagickexport_la_LIBADD = \
	$(KOFFICE_LIBS) \
	$(top_builddir)/krita/libkritacommon.la

libkritamagickimport_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined
libkritamagickimport_la_LIBADD = \
	$(KOFFICE_LIBS) \
	$(top_builddir)/krita/libkritacommon.la

INCLUDES= \
	-I$(srcdir) \
	 $(KOFFICE_INCLUDES) \
	-I$(top_srcdir)/krita \
	-I$(top_srcdir)/krita/core \
	-I$(top_srcdir)/krita/ui \
	$(all_includes) 

service_DATA = krita_magick_import.desktop krita_magick_export.desktop
servicedir = $(kde_servicesdir)

libkritamagickimport_la_SOURCES = magickimport.cpp
libkritamagickexport_la_SOURCES = magickexport.cpp

METASOURCES = AUTO



[Attachment #14 (application/pgp-signature)]

_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic