[Qt-embedded-interest] QImage Format and YCbCr Conversion
Bryce Salmi
Bryce.Salmi at zoran.com
Fri Jul 17 16:48:53 CEST 2009
Qt List,
I changed the write function to implement the fcntl.h open and write
functions which now give me the correct colors to the screen. Now it's
a matter of finding out how to get graphics to the screen (I can't wait
to get that analog clock to appear!
Bryce
-----Original Message-----
From: qt-embedded-interest-bounces at trolltech.com
[mailto:qt-embedded-interest-bounces at trolltech.com] On Behalf Of Bryce
Salmi
Sent: Friday, July 17, 2009 9:01 AM
To: qt-embedded-interest at trolltech.com
Subject: Re: [Qt-embedded-interest] QImage Format and YCbCr Conversion
Tom and Qt list,
Thank you for your email, you have been a huge help! I did manage
to figure out how to use the format() function after I sent the email,
but had been trying for at least a day or so to get the right syntax.
One thing I would suggest would be the addition of small example lines
for some or all functions? I know that's a huge suggestion given the
size of Qt but I really have found that a large part of my problems are
figuring out what the correct syntax for some of the functions like
format, bits, etc are. I will use your suggestions and hopefully figure
this out!
By the way, is there any significance to an all green screen? I know
it's probably hardware dependent for the color (mine accepts YCbCr).
What I am trying to figure out is if I am actually sending the full data
to the screen (wouldn't there at least be some sort of garbage on the
output?) or maybe repeating the first pixel over the entire screen
(coordinates 0,0). My copying function at the moment looks like:
const unsigned char* pimagedata;
Unsigned char* bufferimage;
Pimagedata = img.bits();
Bufferimage = (unsigned char *)pimagedata;
For (i=0, i<115199, i++){
My_screen << *(bufferimage+i);
{
That so far is the best way I can figure out to get data to the screen,
it will be easier knowing what I am sending to the screen first so I can
tell what the effects are. It would be nice to find out a faster way
than a for loop to send data to the screen but so far this is what
works.
Sincerely,
Bryce
-----Original Message-----
From: Tom Cooksey [mailto:thomas.cooksey at nokia.com]
Sent: Friday, July 17, 2009 2:47 AM
To: qt-embedded-interest at trolltech.com
Cc: Bryce Salmi
Subject: Re: [Qt-embedded-interest] QImage Format and YCbCr Conversion
> Qt List,
> So I finally managed to get some sort of data to the screen!
> Thank you for all the help and suggestions. If it is of any
> significance (probably not) most of the screen is green. Anyway,
> my screen wants to see YCbCr pixels so I must convert, and I do
> have a conversion from a previous project that used C but not Qt.
> So my questions are:
>
>
> * How to I know what image format is passed to the blit
> function?
QScreen::blit() passes you a QImage. You can find out the pixel format
using QImage::format().
> * Can I simply use the QImage::Format_ARGB32; or
> similar in the connect member to specify?
The format Qt chooses for window surfaces depends on weather the
surface needs an alpha channel or not. If an alpha channel isn't
needed, it will simply use the same format as the screen is in, as
returned by QScreen::pixelFormat(). If an alpha channel is needed, the
format is based on QScreen::depth() and you can see the selection
algorithm in QWSMemorySurface::preferredImageFormat() in
qwindowsurface_qws.cpp. Although I guess you probably don't want top-
level window transparency?
> * What is the best way
> to go about ripping the R,G,and B values from the data.
You can thus get a pointer to the raw data using const version of
QImage::bits() (make you you use the const version, otherwise it will
do a copy!). You can then access the pixel data directly.
Alternetively, you could also use QImage::pixel() which will return a
QRgb which allow accessing Red, Green & Blue channels seperately -
although doing that will be significantly slower.
Cheers,
Tom
_______________________________________________
Qt-embedded-interest mailing list
Qt-embedded-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-embedded-interest
More information about the Qt-embedded-interest
mailing list