help!!!problem about inherit from KHtmlParts

Leo Savernik l.savernik at aon.at
Wed Sep 17 13:19:02 BST 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am Mittwoch, 17. September 2003 12:37 schrieb zdx3:
[...]
> >Use a data: URL - see the posts from Leo Savernik on this list.
> my problem is this:
> 
> i have a file that be compressed in especially format
> i decompress it and fetch html code to a QString and fetch image that is
> used by html data to a unsigned char *buffer 
> when do this
> begin( );
> write( "<html><body><img src="test.png">test img</body></html>" );
> end( );
> 
> KHtmlPart donnt know where to get the img data,my img data is in the
> unsigned char * buffer. 
> i try many methods but i am going and coming

If you want to use data urls you have to use base64 encoding for binary data, 
otherwise strange things happen. Convert it as follows:

#include <kmdcodec.h>
...
QByteArray ba;
ba.assign(buffer, buf_len);
QCString b64 = KCodec::base64Encode(ba);

begin();
write("<html><body><img src='data:image/png;base64,"
	+QString(b64)+"'>...</body></html>");
end();


It would be faster to use QMimeSourceFactory, but khtml doesn't support this.

Don't forget to update kdelibs/kio, it contains vital bugfixes for data urls.
> 
[...]

mfg
	Leo
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE/aFE3j5jssenUYTsRAppJAJ9ZYA6sjCEIhiExayd50lhAmcSE8wCfaXqg
UGqJjuHOZhsxLTeWhx443So=
=Jl9B
-----END PGP SIGNATURE-----





More information about the kfm-devel mailing list