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.
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,
_
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.
Code:
#include "image_rw.h"
#include "ui_image_rw.h"
#include <QFile>
#include <QBuffer>
#include <QDebug>
namespace
{
const char* MINI_IMAGE = ":/mini.jpg";
}
image_rw
::image_rw(QWidget *parent
) : ui(new Ui::image_rw)
{
ui->setupUi(this);
this->setAttribute( Qt::WA_TranslucentBackground );
this->setWindowFlags(Qt::FramelessWindowHint);
image.load(MINI_IMAGE);
QImage img
= image.
convertToFormat(QImage::Format_RGBA8888,Qt
::AutoColor);
img.save(&bufferrgb, "RGBA8888");
img.save(":/image1.rgba","RGBA8888");
img.format();
qDebug() << img.format() << endl;
}
its giving me no 17 in terminal. but no image get save in folder.
thank you in advance.
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,
_
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.
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.
Re: Convert JPG image to RGBA or 32 bit RGB formate to display on Device framebuffer
Quote:
Originally Posted by
anjani.gandhi
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
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,
_