[Interest] QIcon from ARGB32 data

Filip Piechocki fpiechocki at gmail.com
Fri Jun 13 07:26:15 CEST 2014


On Jun 13, 2014 5:58 AM, "Filip Piechocki" <fpiechocki at gmail.com> wrote:
>
> Hu

That was supposed to be "Hi" :)

>
>
> On Fri, Jun 13, 2014 at 12:00 AM, Damian Ivanov <damianatorrpm at gmail.com>
wrote:
>>
>> Hello,
>>
>> I'm trying to show a QIcon from ARGB32 data which come from dbus,
>
>
> Okay, so this means that you have raw pixel data, yes?
>
>>
>> any help suggestions how to do that?
>>
>> I have a QByteArray which contains the data, I tried
>>
>> QImage image;
>> image.loadFromData(myByteArray);
>
>
> and if you have raw pixel data, than using loadFromData() is not right as
you might read the docs and they say:
> "The loader attempts to read the image using the specified format, e.g.,
PNG or JPG. If format is not specified (which is the default), the loader
probes the file for a header to guess the file format."
>
> The file format is JPG, PNG, BMP and ARGB32 is the image format. All
those file formats can store the image with this given image format. So you
need to know the width and height of the image and use:
>
> QImage image(myByteArray.constData(), width, height,
QImage::Format_ARGB32);
>
> Note that the data has to live as long as QImage and all it's undetached
copies.
>
> Then you can use the code below.
>
>>
>> QPixmap pixmap = QPixmap::fromImage(image);
>>
>> return QIcon(pixmap) ;
>> unfortunately this doesn't show the icon.
>>
>> Thanks in advance.
>> Damian
>
>
> BR,
> Filip
>
>>
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140613/b695a97b/attachment.html>


More information about the Interest mailing list