}
drawKdenliveTitle( producer, buffer, width, height, position );
}
-
+
static void qscene_delete( void *data )
{
QGraphicsScene *scene = ( QGraphicsScene * )data;
loadFromXml( producer, scene, mlt_properties_get( producer_props, "xmldata" ), mlt_properties_get( producer_props, "templatetext" ) );
mlt_service_cache_put( MLT_PRODUCER_SERVICE( producer ), "qscene", scene, 0, ( mlt_destructor )qscene_delete );
}
-
+
g_mutex.unlock();
//must be extracted from kdenlive title
p1.begin( &img );
p1.setRenderHints( QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::HighQualityAntialiasing );
//| QPainter::SmoothPixmapTransform );
-
- QRectF m_start = stringToRect( QString( mlt_properties_get( producer_props, "startrect" ) ) );
- QRectF m_end = stringToRect( QString( mlt_properties_get( producer_props, "endrect" ) ) );
-
- if (m_start.isNull() && m_end.isNull()) {
- scene->render( &p1 );
+
+ const QRectF start = stringToRect( QString( mlt_properties_get( producer_props, "startrect" ) ) );
+ const QRectF end = stringToRect( QString( mlt_properties_get( producer_props, "endrect" ) ) );
+ const QRectF source( 0, 0, width, height );
+
+ if (end.isNull()) {
+ if (start.isNull())
+ scene->render( &p1 );
+ else
+ scene->render( &p1, start, source );
}
else {
- QPointF topleft=m_start.topLeft()+( m_end.topLeft()-m_start.topLeft() )*position;
- QPointF bottomRight=m_start.bottomRight()+( m_end.bottomRight()-m_start.bottomRight() )*position;
- const QRectF r1( 0, 0, width, height );
- const QRectF r2( topleft, bottomRight );
- scene->render( &p1, r1, r2 );
+ QPointF topleft = start.topLeft() + ( end.topLeft() - start.topLeft() ) * position;
+ QPointF bottomRight = start.bottomRight() + ( end.bottomRight() - start.bottomRight() ) * position;
+ const QRectF r1( topleft, bottomRight );
+ scene->render( &p1, r1, source );
}
p1.end();
uint8_t *pointer=img.bits();
QString replacementText = QString::fromUtf8(templateText);
doc.setContent(data);
QDomNodeList titles = doc.elementsByTagName( "kdenlivetitle" );
- int maxZValue = 0;
+ QTransform transform;
+ if ( doc.documentElement().hasAttribute("width") ) {
+ int originalWidth = doc.documentElement().attribute("width").toInt();
+ int originalHeight = doc.documentElement().attribute("height").toInt();
+ if (originalWidth != scene->width() || originalHeight != scene->height()) {
+ transform = QTransform::fromScale ( scene->width() / originalWidth, scene->height() / originalHeight);
+ }
+ }
if ( titles.size() )
{
{
QPointF p( items.item( i ).namedItem( "position" ).attributes().namedItem( "x" ).nodeValue().toDouble(),
items.item( i ).namedItem( "position" ).attributes().namedItem( "y" ).nodeValue().toDouble() );
+ if ( transform != QTransform() ) p = QPointF(p.x() * transform.m11(), p.y() * transform.m22());
gitem->setPos( p );
gitem->setTransform( stringToTransform( items.item( i ).namedItem( "position" ).firstChild().firstChild().nodeValue() ) );
int zValue = items.item( i ).attributes().namedItem( "z-index" ).nodeValue().toInt();
- if ( zValue > maxZValue ) maxZValue = zValue;
gitem->setZValue( zValue );
+ if ( transform != QTransform() ) gitem->setTransform( transform, true );
//gitem->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
}
if ( items.item( i ).nodeName() == "background" )
else if ( items.item( i ).nodeName() == "startviewport" )
{
QString rect = items.item( i ).attributes().namedItem( "rect" ).nodeValue();
-
+ if ( transform != QTransform() ) {
+ rect = rectTransform( rect, transform );
+ }
mlt_properties_set( producer_props, "startrect", rect.toUtf8().data() );
}
else if ( items.item( i ).nodeName() == "endviewport" )
{
QString rect = items.item( i ).attributes().namedItem( "rect" ).nodeValue();
+ if ( transform != QTransform() ) {
+ rect = rectTransform( rect, transform );
+ }
mlt_properties_set( producer_props, "endrect", rect.toUtf8().data() );
}
}
}
+ if ( mlt_properties_get( producer_props, "startrect") == mlt_properties_get( producer_props, "endrect") )
+ mlt_properties_set( producer_props, "endrect", "" );
return;
}
+QString rectTransform( QString s, QTransform t )
+{
+ QStringList l = s.split( ',' );
+ return QString::number(l.at(0).toDouble() * t.m11()) + ',' + QString::number(l.at(1).toDouble() * t.m22()) + ',' + QString::number(l.at(2).toDouble() * t.m11()) + ',' + QString::number(l.at(3).toDouble() * t.m22());
+}
+
QString colorToString( const QColor& c )
{
QString ret = "%1,%2,%3,%4";
/* Obtain properties of producer */
mlt_properties producer_props = MLT_PRODUCER_PROPERTIES( producer );
- *width = mlt_properties_get_int( properties, "rescale_width" );
- *height = mlt_properties_get_int( properties, "rescale_height" );
+ *width = mlt_properties_get_int( properties, "width" );
+ *height = mlt_properties_get_int( properties, "height" );
/* Allocate the image */
int size = *width * ( *height ) * 4;
else refresh_kdenlivetitle( producer, *buffer, *width, *height, position, 0);
/* Update the frame */
mlt_properties_set_data( properties, "image", *buffer, size, mlt_pool_release, NULL );
-
+
mlt_log_debug( MLT_PRODUCER_SERVICE( producer ), "width:%d height:%d %s\n", *width, *height, mlt_image_format_name( *format ) );
}
producer->get_frame = producer_get_frame;
producer->close = ( mlt_destructor )producer_close;
mlt_properties_set( properties, "resource", filename );
- mlt_properties_set_int( properties, "aspect_ratio", 1 );
+ //mlt_properties_set_int( properties, "aspect_ratio", 1 );
read_xml(properties);
return producer;
}