[Qt-interest] Quicktime C -> QImage

"Alexander Carôt" alexander_carot at gmx.net
Mon Apr 19 17:35:29 CEST 2010


Hello again (forgot the attachement),

regarding my color problem I attached a screenshot of the actual image I get when mapping the pixels of a CGImage onto a QImage: The image is kind of blue/white (pillow should be red, pullover shuld be green and skin white).

The full mapping sequence looks like this:

*****************************
CGImageRef image = NULL;

size_t width, height, rowBytes, bitsPerComponent;
CVPixelBufferLockBaseAddress( pixelBuffer, 0 );
rowBytes = CVPixelBufferGetBytesPerRow( pixelBuffer );
baseAddr = CVPixelBufferGetBaseAddress( pixelBuffer );
width = CVPixelBufferGetWidth( pixelBuffer );
height = CVPixelBufferGetHeight( pixelBuffer );
colorspace = CGColorSpaceCreateDeviceRGB();
CVBufferRetain( pixelBuffer );
provider = CGDataProviderCreateWithData( pixelBuffer, baseAddr, rowBytes *height, releaseAndUnlockThis );
image = CGImageCreate( width, height, 8, 32, rowBytes, colorspace, 
kCGImageAlphaNoneSkipFirst, provider, NULL, true, kCGRenderingIntentDefault );

unsigned char *rawData = new unsigned char[1000000];
unsigned char backup;

CFDataRef data = CGDataProviderCopyData(CGImageGetDataProvider(image));
rawData = (unsigned char*) CFDataGetBytePtr(data);
 
if (data != NULL){
  currentObject->displayImage = new QImage(rawData,320,240,QImage::Format_RGB32);   
  currentObject->update();
}   
*****************************
 
I already changed the formats but this made it even worse. Furthermore I did a manua byte swap of the raw data buffer:

  for (int i=0;i<100000;i=i+2){
    backup = rawData[i];
    rawData[i]=rawData[i+1];
    rawData[i+1] = backup;
  } 
 
but this painted swapped range in green.

I anyone might know what the problem might be I'd appreciate any hint.

Thanks a lot in advance

-- A l e x



-------- Original-Nachricht --------
> Datum: Mon, 19 Apr 2010 16:47:54 +0200
> Von: "Alexander Carôt" <alexander_carot at gmx.net>
> An: Stephen Chu <stephen at ju-ju.com>, qt-interest at trolltech.com
> Betreff: Re: [Qt-interest] Quicktime C -> QImage

> > Also pay attention to byte-ordering. QImage::Format_RGB32 and 
> > Format_ARGB32 assume that the 32-bit pixel is in host endian. That is, 
> > on a big-endian machine like PowerPC, the bytes in the buffer are in 
> > ARGBARG... sequence while on a little-endian one like x86, they are 
> > GBRAGBRA...
> >
> > >>From my (painful) experience dealing with Apple, they mostly assume 
> > ARGBARGB sequence regardless of host endian. Unfortunately, Qt does not 
> > provide an option to use reverse byte order image buffer: 
> > <http://bugreports.qt.nokia.com/browse/QTBUG-5200>
> 
> allright ! That might be the reason why my image has wrong colors: It
> looks like a Blue/White image with some additional colors. So - I might need to
> change the order manually then. Let's see. Exiting ;-)
> 
> Thanks and best
> 
> -- A l e x
> 
> 
> 
>  
> > HTH
> > 
> > -- 
> > Stephen Chu
> 
> -- 
> http://www.carot.de
> http://www.triologue.de
> Email : Alexander at Carot.de
> Tel.: +49 (0)177 5719797
> 
> 
> 
> GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest

-- 
http://www.carot.de
http://www.triologue.de
Email : Alexander at Carot.de
Tel.: +49 (0)177 5719797



GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome

-- 
http://www.carot.de
http://www.triologue.de
Email : Alexander at Carot.de
Tel.: +49 (0)177 5719797



GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome
-------------- next part --------------
A non-text attachment was scrubbed...
Name: colorProblem.tiff
Type: image/tiff
Size: 89656 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100419/aad449d5/attachment.tiff 


More information about the Qt-interest-old mailing list