frei0r/configure: use CFLAGS so I can tell the test where to find frei0r.h
[melted] / src / modules / qimage / qimage_wrapper.cpp
index 168796d..63cff87 100644 (file)
 
 #include "qimage_wrapper.h"
 #include <qimage.h>
+
+
+#include "config.h"
+
+#ifdef USE_KDE
+#include <kinstance.h>
+#include <kimageio.h>
+#endif
+
 #include <cmath>
 
 extern "C" {
 
 #include <framework/mlt_pool.h>
 
+#ifdef USE_KDE
+static KInstance *instance = 0L;
+#endif
+
 static void qimage_delete( void *data )
 {
        QImage *image = ( QImage * )data;
        delete image;
+#ifdef USE_KDE
+       if (instance) delete instance;
+       instance = 0L;
+#endif
 }
 
 static void clear_buffered_image( mlt_properties producer_props, uint8_t **current_image, uint8_t **current_alpha )
@@ -57,6 +74,16 @@ static void assign_buffered_image( mlt_properties producer_props, uint8_t *curre
        mlt_events_unblock( producer_props, NULL );
 }
 
+void init_qimage()
+{
+#ifdef USE_KDE
+       if (!instance) {
+           instance = new KInstance("qimage_prod");
+           KImageIO::registerFormats();
+       }
+#endif
+}
+
 void refresh_qimage( mlt_frame frame, int width, int height )
 {
        // Obtain a previous assigned qimage (if it exists) 
@@ -216,7 +243,7 @@ void refresh_qimage( mlt_frame frame, int width, int height )
 
        if ( update_cache )
        {
-               mlt_frame cached = mlt_frame_init( );
+               mlt_frame cached = mlt_frame_init( MLT_PRODUCER_SERVICE( producer ) );
                mlt_properties cached_props = MLT_FRAME_PROPERTIES( cached );
                mlt_properties_set_int( cached_props, "width", current_width );
                mlt_properties_set_int( cached_props, "height", current_height );