Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QImage return null for format RGBA8888
Forum Updated to NodeBB v4.3 + New Features

QImage return null for format RGBA8888

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 854 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Chakravarthi
    wrote on last edited by
    #1

    I'm working on Qt application and I'm new to Qt, when I'm using Qimage to allocate the memory for RGBA8888 it returns null. However same call with RGB888 returns memory allocated. Code is given below:

    QImage *img_32 = nullptr;
    QImage *img_24 = nullptr;

    img_32 = new QImage((unsigned char*)data_ptr,width,hight,bytesperline,QImage::Format_RGBA8888); /*RGB32 color format */

    In debug window img_32 is "0"

    img_24 = new QImage((unsigned char*)data_ptr,width,hight,bytesperline,QImage::Format_RGB888); /*RGB24 color format */
    In debug window img_24 is non-zero value.

    For rendering image i'm using setPixmap(QPixmap).

    Queries:

    1. Is it right format for RGB32 ?
    2. Why RGB32 format gives NULL pointer.
    3. I want to render UYVY also, but Qt does not support UYVY. How to render UYVY in Qt ?

    Regards,
    Kulkarni.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Your debug window is wrong (maybe due to optimizations of the compiler) and it has nothing to do with Qt since you're allocation a new object on the heap which will never return a nullptr (maybe in out-of-memory situations but then you would be unable to debug).
      And why do you allocate it in the heap instead just using an object?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved