[Qt-interest] how to read bitmap emdedded in XML

Andre Somers andre at familiesomers.nl
Tue Aug 17 20:40:27 CEST 2010


  Op 17-8-2010 19:39, Eckhard Jokisch schreef:
> Am Dienstag 17 August 2010, 18:05:58 schrieb Andre Somers:
>>    Op 17-8-2010 17:25, Eckhard Jokisch schreef:
>>> Hi,
>>> how can I get this part of an XML-file into a QPixmap?
>>> The bitmap data is embedded in the XML-File.
>>> The problem is, that the file "picture_1.png" does not exist yet and is
>>> the final target to store the QPixmap in.
>>>
>>> 	<tag name="ID_Object_1" type="CF_BITMAP" data="picture_1.png">
>>>
>>> iVBORw0KGgoAAAANSUhEUgAAAoAAAAHgCAIAAAC6s0uzAAAACXBIWXMAAA7DAAAOwwHHb6hkA
>>> AAg
>>> AElEQVR4nOy913McV7buuf6KPu+nYx66JVK08N4UTAEgvCsUPEkZkqJEgkb03sAQ9Fb03gok
>>> 6A1o
>>> ZFoS5/aZMzEd8zSac5/moSPuvX9Bz8NOJLKysqqyTK5voTIRX4QoICu/3/62WTuzHNGyj47p
>>> f3fy ......
>>>
>>> 	</tag>
>>>
>>> Thanks for any hint
>> Looks like that data is base64 encoded. QByteArray has functions to deal
>> with that, and a QImage can be created from data that's already in
>> memory. You connect the dots :-)
>>
>> André
>>
> Thanks for the answer.
> Unfortunately after:
>
>                  image->fromData(bA.toHex());
>                  int format = image->format();
> the format is 0.
>
> How could I fix this?
Read in the documentation what toHex actually does?
You are looking for QByteArray::fromBase64, I believe...

André



More information about the Qt-interest-old mailing list