[Interest] Binary file embedded in Resources to std::istream
karl.ruetz at ruetzdogz.com
Fri Aug 2 22:05:55 CEST 2013
I'd try QDataStream.
use >> operator or readBytes method to read
use << operator or writeBytes() method to write.
On 2013-08-02 13:18, Rollastre Prostrit wrote:
> Hi Qters:
to vicissitudes of a third party library I'm using I have to read
bytes of png files (binary files) embedded in the resources via
a std::istream. I have been struggling quite a bit with this and
googling a lot without success. Maybe this is something that it is easy
> to solve but I haven't succeeded with it yet.
> I use this
> QFile f(":/images/file.png");
> if (!f.exist())
> if (f.size()<=0)
> if (!f.isReadable())
> QByteArray bytes = f.readAll();
> char* bb =
> std::string str;
> for (int i=0; i<s; ++i)
> str +=
> stringstream stream;
> stream << str;
> I use strings
here because some of the tens of articles I've read
> suggested it. It
doesn't seem to work, though. If I dump the bytes to a
> temp file, I
see the file becomes corrupted. There is an extra empty
> byte right
after the PNG header. My guess is that the zero-end byte is
everything up. But I admit that I don't find any solution for this.
Has somebody faced this problem and/or can see what/how is the
> Thanks in advance!
> Interest mailing
> Interest at qt-project.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Interest