Results 1 to 7 of 7

Thread: Convert JPG image to RGBA or 32 bit RGB formate to display on Device framebuffer

  1. #1
    Join Date
    Dec 2016
    Posts
    11
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Post Convert JPG image to RGBA or 32 bit RGB formate to display on Device framebuffer

    I have jpg image. I want to convert it in RGBA format because my device(AM437x EVM) frame buffer uses rgba format only. I want image to display direct on fb without ui->label. i am able to display pre converted rgba image in frame buffer.but i want to achieve this task from Qt.
    I tried with converttoformat() function. although it converts file, i checked it using file->format() return value. but not able to save any file except jpg and png.and not able to display on frame buffer too.Please help me out for this conversion method or suggest me any other method to display jpg on my device frame buffer.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Convert JPG image to RGBA or 32 bit RGB formate to display on Device framebuffer

    QImage loads image data, decodes it according to the file format and presents it as a pixel buffer.
    If the buffer format is different then the one you need you convert it to the one you do.

    Once you have the pixel data in your target format you use it anyway you see fit.

    Cheers,
    _

  3. #3
    Join Date
    Dec 2016
    Posts
    11
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Post Re: Convert JPG image to RGBA or 32 bit RGB formate to display on Device framebuffer

    Thank you for reply. i am here attaching my code. please suggest me which type of buffer i should take in order to save rgba formate.

    Qt Code:
    1. #include "image_rw.h"
    2. #include "ui_image_rw.h"
    3. #include <QFile>
    4. #include <QBuffer>
    5. #include <QDebug>
    6.  
    7. namespace
    8. {
    9. const char* MINI_IMAGE = ":/mini.jpg";
    10. }
    11.  
    12. image_rw::image_rw(QWidget *parent) :
    13. QMainWindow(parent),
    14. ui(new Ui::image_rw)
    15. {
    16. ui->setupUi(this);
    17. this->setAttribute( Qt::WA_TranslucentBackground );
    18. this->setWindowFlags(Qt::FramelessWindowHint);
    19.  
    20. QImage image;
    21. image.load(MINI_IMAGE);
    22. QImage img = image.convertToFormat(QImage::Format_RGBA8888,Qt::AutoColor);
    23. QBuffer bufferrgb(&im);
    24. bufferrgb.open(QIODevice::WriteOnly);
    25. img.save(&bufferrgb, "RGBA8888");
    26. img.save(":/image1.rgba","RGBA8888");
    27. img.format();
    28. qDebug() << img.format() << endl;
    29. }
    To copy to clipboard, switch view to plain text mode 
    its giving me no 17 in terminal. but no image get save in folder.
    thank you in advance.
    Last edited by anda_skoa; 21st December 2016 at 12:50. Reason: missing [code] tags

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Convert JPG image to RGBA or 32 bit RGB formate to display on Device framebuffer

    RGAB8888 is not a standard image I/O format. Is that an image format plugin you wrote?
    Have you debugged why it is not working?

    Cheers,
    _

  5. #5
    Join Date
    Dec 2016
    Posts
    11
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Post Re: Convert JPG image to RGBA or 32 bit RGB formate to display on Device framebuffer

    yes sir i debbug it.it doesn't shows any error.but it also dont save any image.
    i just come to know that Qt doesnt supports RGBA image format for file reading and writing. i debug this code but no file is created. and if i replace JPG/PNG/PPM or any other in place of RGBA in line no 26 and 27 it saves image in folder. guide me how can I set buffer and how i should use it to get RGBA file of my image.

  6. #6
    Join Date
    Dec 2016
    Posts
    11
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Convert JPG image to RGBA or 32 bit RGB formate to display on Device framebuffer

    thank you.Problem was there in buffer only. I open a file and write data in it.thas it. I can now see my rgba image on board.

  7. #7
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Convert JPG image to RGBA or 32 bit RGB formate to display on Device framebuffer

    Quote Originally Posted by anjani.gandhi View Post
    i just come to know that Qt doesnt supports RGBA image format for file reading and writing.
    Yes, that's what I wrote, there is no standard image plugin called "RGAB888".

    Which is why I asked if you had written your own QImageWriter that does that and if you had debugged it.

    Apparently, you don't have such an implementation, so obviously saving in an unknow format would not work.

    Quote Originally Posted by anjani.gandhi View Post
    guide me how can I set buffer and how i should use it to get RGBA file of my image.
    You can either write the pixel data directly into a file, or provide an image plugin that does that.
    In the first case you need to call QImage::convertToFormat() after loading, the the second case you can do that in the QImageWriter.

    Cheers,
    _

Similar Threads

  1. Showing 1 bit binary PNG as 32bit RGBA image
    By Charvi in forum Qt Programming
    Replies: 1
    Last Post: 22nd October 2015, 17:11
  2. Replies: 0
    Last Post: 26th July 2012, 09:32
  3. problem with the framebuffer on an ARM device
    By ilpaso in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 23rd January 2011, 06:06
  4. Test FrameBUffer On Ubuntu 10.10 i386 Cant Display ?
    By Thành Viên Mới in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 17th November 2010, 03:10
  5. "Error opening framebuffer device"
    By rishiraj in forum Installation and Deployment
    Replies: 8
    Last Post: 1st April 2009, 06:29

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.