]> git.sesse.net Git - mlt/commitdiff
working color conversion
authorMarco Gittler <g.marco@freenet.de>
Sat, 18 Jul 2009 08:56:55 +0000 (10:56 +0200)
committerMarco Gittler <g.marco@freenet.de>
Sat, 18 Jul 2009 08:56:55 +0000 (10:56 +0200)
src/modules/qimage/kdenlivetitle_wrapper.cpp
src/modules/qimage/kdenlivetitle_wrapper.h
src/modules/qimage/producer_kdenlivetitle.c

index c015967d2787445d15ce3f4e027215ed9cae134f..4be56548dd3280c155fde750f4412bb514297e54 100644 (file)
 #include <QtGui/QTextCursor>
 #include "kdenlivetitle_wrapper.h"
 #include <framework/mlt_producer.h>
+
+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;i<width*height*4;i+=4){
-            uint8_t v=i>11000 && 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<width*height*4;i+=4){
+        *buffer++=qRed(*src);
+        *buffer++=qGreen(*src);
+        *buffer++=qBlue(*src);
+        *buffer++=qAlpha(*src);
+        src++;
+    }
+    delete img;
 }
 int Title::loadDocument(const QString& url, QGraphicsPolygonItem* startv, QGraphicsPolygonItem* endv)
 {
index c032330813105e6eb1f83c0c3a81db38c21efd29..c7decbae0703d0337420fb5d9885e48ba94b6a1e 100644 (file)
@@ -28,14 +28,12 @@ class QObject;
 class Title;
 class QGraphicsView;
 class QGraphicsScene;
-QApplication *app;
-Title* titleclass;
 
 class Title: public QObject {
 
     public:
             Title(const QString &);
-            QImage* drawKdenliveTitle(uint8_t*,int,int,double);
+            void drawKdenliveTitle(uint8_t*,int,int,double);
     private:
             QString m_filename;
             int  loadFromXml(QDomDocument doc, QGraphicsPolygonItem* /*startv*/, QGraphicsPolygonItem* /*endv*/);
index 9c5a68843062923aee45539d792a5ff74e26ce8e..64a8e8710a4ba9a2a0f1cd2c8ddf596a4230f873 100644 (file)
  */
 
 #include <framework/mlt.h>
-//#include "frei0r_helper.h"
 #include <stdlib.h>
 #include <string.h>
-//#include <QtCore/QCoreApplication>
-//#include <QtGui/QImage>
 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 );