Results 1 to 1 of 1

Thread: QImage crashers the program or displays wrong image color

  1. #1
    Join Date
    Oct 2017
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default QImage crashers the program or displays wrong image color

    Hi
    I have a dump of camera captured image frames @30 fps (raw format). I am trying to create a video player by displaying these images using QImage simultaneously. The problem is that I do not know the correct format of these raw images. I tried using all the available format options. Using some format caused the images to be displayed with wrong color while with some other formats, the program crashed. Here is my code snippet:
    Qt Code:
    1. void MainWindow::on_pushButton_play_clicked()
    2. {
    3.  
    4. QDirIterator itAmp(Amp_dir, QDirIterator::NoIteratorFlags);// Amp_dir is the image dump directory
    5. while (itAmp.hasNext() )
    6. {
    7. itAmp.next();
    8. if(!(itAmp.fileName().compare(".")) || !(itAmp.fileName().compare(".."))) continue;
    9. QFile Afile(itAmp.filePath());
    10. Afile.open(QFile::ReadOnly);
    11. QByteArray Aarray = Afile.readAll();
    12. unsigned char* Adata = (unsigned char*)&Aarray.data()[0];
    13. QImage Aimage(Adata,640,480,QImage::Format_RGB444);// I Do not know the format of raw image.
    14. ui->amplitude->setPixmap(QPixmap::fromImage(Aimage));
    15. repaint();
    16. Afile.close();
    17. QTest::qWait(1000/30);// wait for said time before displaying next image since we have 30 images in 1 second
    18.  
    19. }
    20.  
    21. }
    To copy to clipboard, switch view to plain text mode 

    It would be very helpful if someone can provide me with a workaround for the format issue or point me to some other approach for creating such video player.
    Last edited by Rishu Singh; 11th October 2017 at 09:45.

Similar Threads

  1. Replies: 3
    Last Post: 14th May 2016, 02:28
  2. how to remove previous image to display new image in QImage
    By iswaryasenthilkumar in forum Newbie
    Replies: 6
    Last Post: 5th January 2015, 10:53
  3. Replies: 3
    Last Post: 11th December 2012, 16:32
  4. Replies: 1
    Last Post: 7th September 2008, 10:47
  5. QTextEdit wrong color
    By thomaspu in forum Qt Programming
    Replies: 3
    Last Post: 18th January 2008, 04:35

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.