qt4 - Qt5: how to determine screen pixel format? -


i'm porting application embedded qt4 qt5. therefore, need equivalent following expression:

qscreen::instance()->pixelformat() 

qscreen not have static instance() function anymore, nor provide pixelformat().

so need determine pixel format of screen. need second argument constructor of qimage.

if following workaround doesn't meet needs, use:
qplatformscreen * qscreen::handle() const.

workaround:
maybe use qscreen::depth , match value proper qimage::format:

qimage::format convertdepthtoformat(int depth) {    qimage::format format = qimage::format_invalid;    switch (depth)    {       case 16:          format = qimage::format_rgb16;          break;        case 32:          format = qimage::format_rgb32;          break;     }    return format; }  int main(int argc, char *argv[]) {     qguiapplication a(argc, argv);      int depth = 0;     foreach (qscreen *screen, qguiapplication::screens())     {        depth = screen->depth();        qdebug() << "depth:" << depth << "-bits";        qimage::format format = convertdepthtoformat(depth);     }     return a.exec();  } 

Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -