From 1bfb4a66553f20e8932be69f4387639ea1be1e6e Mon Sep 17 00:00:00 2001 From: Marco Gittler Date: Sat, 18 Jul 2009 10:56:55 +0200 Subject: [PATCH] working color conversion --- src/modules/qimage/kdenlivetitle_wrapper.cpp | 39 ++++++++------------ src/modules/qimage/kdenlivetitle_wrapper.h | 4 +- src/modules/qimage/producer_kdenlivetitle.c | 6 +-- 3 files changed, 18 insertions(+), 31 deletions(-) diff --git a/src/modules/qimage/kdenlivetitle_wrapper.cpp b/src/modules/qimage/kdenlivetitle_wrapper.cpp index c015967d..4be56548 100644 --- a/src/modules/qimage/kdenlivetitle_wrapper.cpp +++ b/src/modules/qimage/kdenlivetitle_wrapper.cpp @@ -30,15 +30,16 @@ #include #include "kdenlivetitle_wrapper.h" #include + +static Title* titleclass; +static QApplication *app; + extern "C" { void init_qt (const char* c){ titleclass=new Title(QString(c)); } void refresh_kdenlivetitle( uint8_t* buffer, int width, int height , double position){ - QImage* ret=titleclass->drawKdenliveTitle(buffer,width,height,position); - memcpy(buffer,ret->bits(),width*height*4); - delete(ret); - //return (uint8_t*)cpy; + titleclass->drawKdenliveTitle(buffer,width,height,position); } } Title::Title(const QString& filename):m_filename(filename),m_scene(NULL){ @@ -46,7 +47,7 @@ Title::Title(const QString& filename):m_filename(filename),m_scene(NULL){ start =new QGraphicsPolygonItem(QPolygonF(QRectF(100, 100, 600, 600)));; end=new QGraphicsPolygonItem(QPolygonF(QRectF(0, 0, 300, 300)));; } -QImage* Title::drawKdenliveTitle(uint8_t * buffer ,int width,int height,double position){ +void Title::drawKdenliveTitle(uint8_t * buffer ,int width,int height,double position){ if (!m_scene){ int argc=0; char* argv[1]; @@ -59,11 +60,7 @@ QImage* Title::drawKdenliveTitle(uint8_t * buffer ,int width,int height,double p } //must be extracted from kdenlive title - //qDebug() << width << height; QImage *img=new QImage(width,height,QImage::Format_ARGB32); - //QImage img((uchar*)buffer,width,height,width*4,QImage::Format_ARGB32); - //img->fill(Qt::transparent); - //memset(buffer,127,width*height+4); QRectF rstart=start->boundingRect(); QRectF rend=end->boundingRect(); QPointF topleft=rstart.topLeft()+(rend.topLeft()-rstart.topLeft())*position; @@ -73,20 +70,16 @@ QImage* Title::drawKdenliveTitle(uint8_t * buffer ,int width,int height,double p p1.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::HighQualityAntialiasing);//|QPainter::SmoothPixmapTransform ); m_scene->render(&p1,QRect(0,0,width,height),QRectF(topleft,bottomRight)); p1.end(); - uint8_t* pointer=img->bits(); - for (int i=0;i11000 && i< 35000 ?255:0; - uint8_t a=pointer[0],r=pointer[1],g=pointer[2],b=pointer[3]; - pointer[0]=g;//g - pointer[1]=r;//r - pointer[2]=b;//b - pointer[3]=a;//a - //qDebug() << a; - pointer+=4; - } - img->save("test.png"); - return img; - //qDebug() << img.hasAlphaChannel(); + uint8_t *pointer=img->bits(); + QRgb* src = (QRgb*) pointer; + for (int i=0;i -//#include "frei0r_helper.h" #include #include -//#include -//#include extern void init_qt(); extern void refresh_kdenlivetitle(uint8_t*,int,int,double); @@ -48,12 +45,11 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form // Update the frame mlt_properties_set_data( properties, "image", *buffer, size, mlt_pool_release, NULL ); - + //cache later ?? if ( 1 ) { // Allocate the image *format = mlt_image_rgb24a; - //*format = mlt_image_yuv422; mlt_position in = mlt_producer_get_in( producer ); mlt_position out = mlt_producer_get_out( producer ); mlt_position time = mlt_frame_get_position( frame ); -- 2.39.2