X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1a75935d3fae99053ca86d9120caa7be37935236..77c1fa98ce364fb1c2b31a82bdd04f3a0ab75424:/src/richtext/richtextbuffer.cpp diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index b03ac28b99..b77bca81bf 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -8173,16 +8173,33 @@ bool wxRichTextImageBlock::Load(wxImage& image) // Write data in hex to a stream bool wxRichTextImageBlock::WriteHex(wxOutputStream& stream) { - wxString hex; - int i; - for (i = 0; i < (int) m_dataSize; i++) + const int bufSize = 512; + char buf[bufSize+1]; + + int left = m_dataSize; + int n, i, j; + j = 0; + while (left > 0) { - hex = wxDecToHex(m_data[i]); - wxCharBuffer buf = hex.ToAscii(); + if (left*2 > bufSize) + { + n = bufSize; left -= (bufSize/2); + } + else + { + n = left*2; left = 0; + } - stream.Write((const char*) buf, hex.length()); - } + char* b = buf; + for (i = 0; i < (n/2); i++) + { + wxDecToHex(m_data[j], b, b+1); + b += 2; j ++; + } + buf[n] = 0; + stream.Write((const char*) buf, n); + } return true; } @@ -8194,7 +8211,7 @@ bool wxRichTextImageBlock::ReadHex(wxInputStream& stream, int length, int imageT if (m_data) delete[] m_data; - wxString str(wxT(" ")); + wxChar str[2]; m_data = new unsigned char[dataSize]; int i; for (i = 0; i < dataSize; i ++)