/***************************************************************************
                            QImageIO.cpp -  description
                             -------------------
    begin                : Wed Nov 21 17:05:56 2001
    copyright            : (C) 2000-2001 Lost Highway Ltd. All rights reserved.
    email                : Lost_Highway@tipitina.demon.co.uk
    generated by         : duke@tipitina on Wed Nov 21 17:05:56 2001, using kalyptus 0.9.
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
***************************************************************************/

#define _BOOL_H_
#include <qimage.h>
#include <qstring.h>
#include <qcstring.h>

#include <qtjava/QtSupport.h>
#include <qtjava/QImageIO.h>

class QImageIOJBridge : public QImageIO
{
public:
	QImageIOJBridge() : QImageIO() {}
	QImageIOJBridge(QIODevice* ioDevice, const char* format) : QImageIO(ioDevice, format) {}
	QImageIOJBridge(const QString& fileName, const char* format) : QImageIO(fileName, format) {}
	~QImageIOJBridge() {QtSupport::qtKeyDeleted(this);}
};


JNIEXPORT void JNICALL
Java_org_kde_qt_QImageIO_newQImageIO__(JNIEnv *env, jobject obj)
{
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new QImageIOJBridge());
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QImageIO_newQImageIO__Lorg_kde_qt_QIODeviceInterface_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jobject ioDevice, jstring format)
{
static QCString * _qstring_format = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new QImageIOJBridge((QIODevice*) QtSupport::getQt(env, ioDevice), (char*) QtSupport::toCharString(env, format, &_qstring_format)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QImageIO_newQImageIO__Ljava_lang_String_2Ljava_lang_String_2(JNIEnv *env, jobject obj, jstring fileName, jstring format)
{
static QCString * _qstring_format = 0;
static QString * _qstring_fileName = 0;
	if (QtSupport::getQt(env, obj) == 0) {
		QtSupport::setQt(env, obj, new QImageIOJBridge((QString&) * (QString *) QtSupport::toQString(env, fileName, &_qstring_fileName), (char*) QtSupport::toCharString(env, format, &_qstring_format)));
		QtSupport::setObjectForQtKey(env, obj, QtSupport::getQt(env, obj));
	}
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QImageIO_finalize(JNIEnv *env, jobject obj)
{
	if (QtSupport::allocatedInJavaWorld(env, obj)) {
		delete (QImageIO*)QtSupport::getQt(env, obj);
		QtSupport::setQt(env, obj, 0);
	}
	return;
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_QImageIO_image(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)(QImage *) &((QImageIOJBridge*) QtSupport::getQt(env, obj))->image(), "org.kde.qt.QImage");
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QImageIO_status(JNIEnv *env, jobject obj)
{
	return (jint) ((QImageIOJBridge*) QtSupport::getQt(env, obj))->status();
}

JNIEXPORT jstring JNICALL
Java_org_kde_qt_QImageIO_format(JNIEnv *env, jobject obj)
{
	const char * _qcstring;
	_qcstring = (const char *)((QImageIOJBridge*) QtSupport::getQt(env, obj))->format();
	return QtSupport::fromCharString(env, (char *) _qcstring);
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_QImageIO_ioDevice(JNIEnv *env, jobject obj)
{
	return (jobject) QtSupport::objectForQtKey(env, (void *)((QImageIOJBridge*) QtSupport::getQt(env, obj))->ioDevice(), "org.kde.qt.QIODeviceInterface");
}

JNIEXPORT jstring JNICALL
Java_org_kde_qt_QImageIO_fileName(JNIEnv *env, jobject obj)
{
	QString  _qstring;
	_qstring = ((QImageIOJBridge*) QtSupport::getQt(env, obj))->fileName();
	return QtSupport::fromQString(env, &_qstring);
}

JNIEXPORT jint JNICALL
Java_org_kde_qt_QImageIO_quality(JNIEnv *env, jobject obj)
{
	return (jint) ((QImageIOJBridge*) QtSupport::getQt(env, obj))->quality();
}

JNIEXPORT jstring JNICALL
Java_org_kde_qt_QImageIO_description(JNIEnv *env, jobject obj)
{
	QString  _qstring;
	_qstring = ((QImageIOJBridge*) QtSupport::getQt(env, obj))->description();
	return QtSupport::fromQString(env, &_qstring);
}

JNIEXPORT jstring JNICALL
Java_org_kde_qt_QImageIO_parameters(JNIEnv *env, jobject obj)
{
	const char * _qcstring;
	_qcstring = (const char *)((QImageIOJBridge*) QtSupport::getQt(env, obj))->parameters();
	return QtSupport::fromCharString(env, (char *) _qcstring);
}

JNIEXPORT jfloat JNICALL
Java_org_kde_qt_QImageIO_gamma(JNIEnv *env, jobject obj)
{
	return (jfloat) ((QImageIOJBridge*) QtSupport::getQt(env, obj))->gamma();
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QImageIO_setImage(JNIEnv *env, jobject obj, jobject arg1)
{
	((QImageIOJBridge*) QtSupport::getQt(env, obj))->setImage((QImage&) *(QImage *) QtSupport::getQt(env, arg1));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QImageIO_setStatus(JNIEnv *env, jobject obj, jint arg1)
{
	((QImageIOJBridge*) QtSupport::getQt(env, obj))->setStatus((int) arg1);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QImageIO_setFormat(JNIEnv *env, jobject obj, jstring arg1)
{
static QCString * _qstring_arg1 = 0;
	((QImageIOJBridge*) QtSupport::getQt(env, obj))->setFormat((char*) QtSupport::toCharString(env, arg1, &_qstring_arg1));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QImageIO_setIODevice(JNIEnv *env, jobject obj, jobject arg1)
{
	((QImageIOJBridge*) QtSupport::getQt(env, obj))->setIODevice((QIODevice*) QtSupport::getQt(env, arg1));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QImageIO_setFileName(JNIEnv *env, jobject obj, jstring arg1)
{
static QString * _qstring_arg1 = 0;
	((QImageIOJBridge*) QtSupport::getQt(env, obj))->setFileName((QString&) * (QString *) QtSupport::toQString(env, arg1, &_qstring_arg1));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QImageIO_setQuality(JNIEnv *env, jobject obj, jint arg1)
{
	((QImageIOJBridge*) QtSupport::getQt(env, obj))->setQuality((int) arg1);
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QImageIO_setDescription(JNIEnv *env, jobject obj, jstring arg1)
{
static QString * _qstring_arg1 = 0;
	((QImageIOJBridge*) QtSupport::getQt(env, obj))->setDescription((QString&) * (QString *) QtSupport::toQString(env, arg1, &_qstring_arg1));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QImageIO_setParameters(JNIEnv *env, jobject obj, jstring arg1)
{
static QCString * _qstring_arg1 = 0;
	((QImageIOJBridge*) QtSupport::getQt(env, obj))->setParameters((char*) QtSupport::toCharString(env, arg1, &_qstring_arg1));
	return;
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QImageIO_setGamma(JNIEnv *env, jobject obj, jfloat arg1)
{
	((QImageIOJBridge*) QtSupport::getQt(env, obj))->setGamma((float) arg1);
	return;
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QImageIO_read(JNIEnv *env, jobject obj)
{
	return (jboolean) ((QImageIOJBridge*) QtSupport::getQt(env, obj))->read();
}

JNIEXPORT jboolean JNICALL
Java_org_kde_qt_QImageIO_write(JNIEnv *env, jobject obj)
{
	return (jboolean) ((QImageIOJBridge*) QtSupport::getQt(env, obj))->write();
}

JNIEXPORT jstring JNICALL
Java_org_kde_qt_QImageIO_imageFormat__Ljava_lang_String_2(JNIEnv *env, jclass obj, jstring fileName)
{
	 const char*  _qcstring;
static QString * _qstring_fileName = 0;
	_qcstring = (const char *)QImageIOJBridge::imageFormat((QString&) * (QString *) QtSupport::toQString(env, fileName, &_qstring_fileName));
	return QtSupport::fromCharString(env, (char *) _qcstring);
}

JNIEXPORT jstring JNICALL
Java_org_kde_qt_QImageIO_imageFormat__Lorg_kde_qt_QIODeviceInterface_2(JNIEnv *env, jclass obj, jobject arg1)
{
	 const char * _qcstring;
	_qcstring = (const char *)QImageIOJBridge::imageFormat((QIODevice*) QtSupport::getQt(env, arg1));
	return QtSupport::fromCharString(env, (char *) _qcstring);
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_QImageIO_inputFormats(JNIEnv *env, jclass obj)
{
	QStrList  _qlist;
	_qlist = QImageIOJBridge::inputFormats();
	return (jobject) QtSupport::arrayWithQStrList(env, (QStrList *) &_qlist);
}

JNIEXPORT jobject JNICALL
Java_org_kde_qt_QImageIO_outputFormats(JNIEnv *env, jclass obj)
{
	QStrList  _qlist;
	_qlist = QImageIOJBridge::outputFormats();
	return (jobject) QtSupport::arrayWithQStrList(env, (QStrList *) &_qlist);
}

JNIEXPORT void JNICALL
Java_org_kde_qt_QImageIO_defineIOHandler(JNIEnv *env, jclass obj, jstring format, jstring header, jstring flags, jint read_image, jint write_image)
{
static QCString * _qstring_flags = 0;
static QCString * _qstring_header = 0;
static QCString * _qstring_format = 0;
	QImageIOJBridge::defineIOHandler((char*) QtSupport::toCharString(env, format, &_qstring_format), (char*) QtSupport::toCharString(env, header, &_qstring_header), (char*) QtSupport::toCharString(env, flags, &_qstring_flags), (image_io_handler) read_image, (image_io_handler) write_image);
	return;
}

