]> git.sesse.net Git - mlt/blobdiff - src/modules/qimage/qimage_wrapper.cpp
enhance mlt_frame_clone with a deep/shallow parameter
[mlt] / src / modules / qimage / qimage_wrapper.cpp
index a454fd0fdb9690583522cba9d2e6136dfd004321..abcef45449b2a332b5203eb820b961d964ba30a2 100644 (file)
 #include <QtCore/QSysInfo>
 #include <QtCore/QMutex>
 #include <QtCore/QtEndian>
+#include <QtCore/QTemporaryFile>
 #endif
 
 #ifdef USE_EXIF
-#include <exif-data.h>
+#include <libexif/exif-data.h>
 #endif
 
 #include <cmath>
@@ -164,7 +165,7 @@ void refresh_qimage( producer_qimage self, mlt_frame frame, int width, int heigh
        if ( image_idx != self->qimage_idx )
                qimage = NULL;
 
-       if ( ( !qimage && !self->current_image ) || mlt_properties_get_int( producer_props, "_disable_exif" ) != disable_exif)
+       if ( !qimage || mlt_properties_get_int( producer_props, "_disable_exif" ) != disable_exif)
        {
                self->current_image = NULL;
                qimage = new QImage( mlt_properties_get_value( self->filenames, image_idx ) );
@@ -186,6 +187,9 @@ void refresh_qimage( producer_qimage self, mlt_frame frame, int width, int heigh
                                        exif_data_unref(d);
                                }
 
+                               // Remember EXIF value, might be useful for someone
+                               mlt_properties_set_int( producer_props, "_exif_orientation" , exif_orientation );
+                                     
                                if ( exif_orientation > 1 )
                                {
                                      // Rotate image according to exif data
@@ -260,9 +264,14 @@ void refresh_qimage( producer_qimage self, mlt_frame frame, int width, int heigh
 
 #ifdef USE_QT4
                // Note - the original qimage is already safe and ready for destruction
+               if ( qimage->depth() == 1 )
+               {
+                       QImage temp = qimage->convertToFormat( QImage::Format_RGB32 );
+                       delete qimage;
+                       qimage = new QImage( temp );
+               }
                QImage scaled = interp == 0 ? qimage->scaled( QSize( width, height ) ) :
                        qimage->scaled( QSize(width, height), Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
-               QImage temp;
                self->has_alpha = scaled.hasAlphaChannel();
 #endif
 
@@ -341,4 +350,31 @@ void refresh_qimage( producer_qimage self, mlt_frame frame, int width, int heigh
        g_mutex.unlock();
 }
 
+extern void make_tempfile( producer_qimage self, const char *xml )
+{
+       // Generate a temporary file for the svg
+       QTemporaryFile tempFile( "mlt.XXXXXX" );
+
+       tempFile.setAutoRemove( false );
+       if ( tempFile.open() )
+       {
+               // Write the svg into the temp file
+               char *fullname = tempFile.fileName().toUtf8().data();
+
+               // Strip leading crap
+               while ( xml[0] != '<' )
+                       xml++;
+
+               qint64 remaining_bytes = strlen( xml );
+               while ( remaining_bytes > 0 )
+                       remaining_bytes -= tempFile.write( xml + strlen( xml ) - remaining_bytes, remaining_bytes );
+               tempFile.close();
+
+               mlt_properties_set( self->filenames, "0", fullname );
+
+               mlt_properties_set_data( MLT_PRODUCER_PROPERTIES( &self->parent ), "__temporary_file__",
+                       fullname, 0, ( mlt_destructor )unlink, NULL );
+       }
+}
+
 } // extern "C"