[Qt-interest] Quicktime C -> QImage

Stephen Chu stephen at ju-ju.com
Mon Apr 19 02:24:03 CEST 2010


In article <09A0412E-45A5-4114-9576-3FF0CA180813 at gmx.net>,
 Alexander Carot <alexander_carot at gmx.net> wrote:

> Hi all,
> 
> I am using Quicktime video images, which I finally want to display on a 
> QImage. However, I have a problem to actually map the Quicktime image 
> correctly. First I create the image as follows:
> 
> *************
> image = CGImageCreate( width, height, 8, 32, rowBytes, colorspace, 
>                                                    
>                                 kCGImageAlphaNoneSkipFirst, provider, NULL, 
>                                 true, kCGRenderingIntentDefault );

That is a CoreGraphics image reference. How do you actually get a 
QuickTime image?

> and then I thought about using the QImage::setPixel(...) in this way:
> 
> 
> ************
>     unsigned int *pixels = (unsigned int *) image;
>     int i = 0;
>     for (int y = 0; y < 240; y++){
>       for (int x = 0; x < 320; x++){
>         displayImage->setPixel(x,y,pixels[i]);
>         i++;
>       }   
>     }   
> **************

If the "image" variable is the same one you get from CGImageCreate, it's 
just a reference, not a pointer to image buffer. I am surprised it 
doesn't crash.

setPixel is too slow for image construction. You need to create a QImage 
from the external buffer you get from QT or other source: 
http://qt.nokia.com/doc/4.6/qimage.html#QImage-6

Or you can load the QT image directly into a QImage's owned buffer:
http://qt.nokia.com/doc/4.6/qimage.html#bits

HTH.



More information about the Qt-interest-old mailing list