X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmodules%2Fqimage%2Fqimage_wrapper.cpp;h=c07a32c24ee78948dc98ae3d7026fc426ade7d6b;hb=d5b9d2407f283d5db2ae85dd42ab598dc20ad4d5;hp=ed52681cc8453ebdcf202f8d680a26c0b47989f7;hpb=8e6197ff6e2043e70415d7118922ef9b0b740752;p=mlt diff --git a/src/modules/qimage/qimage_wrapper.cpp b/src/modules/qimage/qimage_wrapper.cpp index ed52681c..c07a32c2 100644 --- a/src/modules/qimage/qimage_wrapper.cpp +++ b/src/modules/qimage/qimage_wrapper.cpp @@ -98,7 +98,7 @@ void refresh_qimage( producer_qimage self, mlt_frame frame, int width, int heigh self->current_image = static_cast( mlt_cache_item_data( self->image_cache, NULL ) ); // Check if user wants us to reload the image - if ( mlt_properties_get_int( producer_props, "force_reload" ) ) + if ( mlt_properties_get_int( producer_props, "force_reload" ) || mlt_properties_get_int( producer_props, "_orientation" ) != mlt_properties_get_int( producer_props, "meta.attr.orientation" ) ) { qimage = NULL; self->current_image = NULL; @@ -166,6 +166,44 @@ void refresh_qimage( producer_qimage self, mlt_frame frame, int width, int heigh if ( !qimage->isNull( ) ) { // Store the width/height of the qimage + int exif_orientation = mlt_properties_get_int( producer_props, "meta.attr.orientation" ); + + if ( exif_orientation > 1 ) + { + // Rotate image according to exif data + QImage processed; + QMatrix matrix; + + switch ( exif_orientation ) { + case 2: + matrix.scale( -1, 1 ); + break; + case 3: + matrix.rotate( 180 ); + break; + case 4: + matrix.scale( 1, -1 ); + break; + case 5: + matrix.rotate( 90 ); + matrix.scale( -1, 1 ); + break; + case 6: + matrix.rotate( 270 ); + break; + case 7: + matrix.rotate( 270 ); + matrix.scale( -1, 1 ); + break; + case 8: + matrix.rotate( 90 ); + break; + } + processed = qimage->transformed( matrix ); + delete qimage; + qimage = new QImage( processed ); + } + self->current_width = qimage->width( ); self->current_height = qimage->height( ); @@ -178,6 +216,7 @@ void refresh_qimage( producer_qimage self, mlt_frame frame, int width, int heigh mlt_events_block( producer_props, NULL ); mlt_properties_set_int( producer_props, "_real_width", self->current_width ); mlt_properties_set_int( producer_props, "_real_height", self->current_height ); + mlt_properties_set_int( producer_props, "_orientation", exif_orientation ); mlt_events_unblock( producer_props, NULL ); } else