Re: QByteArray into QPixmap
Quote:
Originally Posted by
yagabey
I am getting an image into a databuffer
What image format?
PS. It's unnecessary to allocate QPixmap on the heap, it's an implicitly shared class.
Re: QByteArray into QPixmap
If it is in an unusual format then you could create a QImage and set its pixels with QImage::setPixel. Note that you should set the image's size before ever calling setPixel.
Re: QByteArray into QPixmap
Except don't use setpixel, as it is very slow. Use bits() directly. More information here: http://www.qtcentre.org/forum/f-qt-p...mpeg-9935.html
Re: QByteArray into QPixmap
The format of the image is jpeg, I also tried to set image size before; but this time a white screen is displayed instead....
Sorry, what's "allocating on the heap" ?
And actually i made it work by using a QDatastream and a QImage(i put the jpeg stream in a temp file then displayed )... But it was slow...
By the way, thanks for your replies...i ask for more... :)
Re: QByteArray into QPixmap
Quote:
The format of the image is jpeg, I also tried to set image size before; but this time a white screen is displayed instead....
Not what format is the original file, but the decoded data. Is it RGB, ARGB, YUV, etc? Knowing this, you will know how to set the pixel data in the image/pixmap.
Re: QByteArray into QPixmap
I am getting the images from a camera. In the datasheet it says that:
" The OV528 takes 8-bit YCbCr 422 progressive video data from an OV7640/8 CameraChip. The camera interface synchronizes with input video data and performs down sampling, clamping and windowing functions with desired resolution, as well as color conversion that is requested by the user through serial bus host commands."
Is that the answer: YCbCr ?
Re: QByteArray into QPixmap
Then you need to convert the data that comes from the camera from YCbCr to RGB. You have to do this before or while constructing the QImage.
Here's something to get you started: http://en.wikipedia.org/wiki/YCbCr.
This article shows you how to convert the data to RGB.
Re: QByteArray into QPixmap
Ok thanks, i ll check it..
Re: QByteArray into QPixmap
Something sticked in my mind..
Isnt that YCbCr or RGB , a matter of color. If that was the problem, shouldn't i see something on the screen ( perhaps with distorted colors). But i see nothing...
Re: QByteArray into QPixmap
Yes, because you're not constructing the image correctly yet. You can do it as pherthyl suggested in his post.
Don't think, just do it!