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

Eckhard Jokisch e.jokisch at orange-moon.de
Tue Aug 17 21:22:07 CEST 2010


Am Dienstag 17 August 2010, 20:40:27 schrieb Andre Somers:
>   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">
> >>> 
> >>> iVBORw0KGgoAAAANSUhEUgAAAoAAAAHgCAIAAAC6s0uzAAAACXBIWXMAAA7DAAAOwwHHb6h
> >>> kA AAg
> >>> AElEQVR4nOy913McV7buuf6KPu+nYx66JVK08N4UTAEgvCsUPEkZkqJEgkb03sAQ9Fb03go
> >>> k 6A1o
> >>> ZFoS5/aZMzEd8zSac5/moSPuvX9Bz8NOJLKysqqyTK5voTIRX4QoICu/3/62WTuzHNGyj47
> >>> p 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é

Yes - thanks. this hint solved my problem.
I read the doc but didn't get it. Maybe I should have taken a longer brake 
during the day ...

Thanks again all of you for helping me out.

Eckhard




More information about the Qt-interest-old mailing list