From: Julian Smart Date: Mon, 11 Jun 2007 17:16:59 +0000 (+0000) Subject: Added a new overload of wxDecToHex and used it in wxRichTextImageBlock::WriteHex X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/f728025eae8e12fc8edd6f48d68fa560f4c399af Added a new overload of wxDecToHex and used it in wxRichTextImageBlock::WriteHex git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46405 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/utils.h b/include/wx/utils.h index af924c4be7..43c6a3c11a 100644 --- a/include/wx/utils.h +++ b/include/wx/utils.h @@ -290,6 +290,7 @@ WXDLLIMPEXP_BASE int wxHexToDec(const wxString& buf); // Convert decimal integer to 2-character hex string WXDLLIMPEXP_BASE void wxDecToHex(int dec, wxChar *buf); +WXDLLIMPEXP_BASE void wxDecToHex(int dec, char* ch1, char* ch2); WXDLLIMPEXP_BASE wxString wxDecToHex(int dec); // ---------------------------------------------------------------------------- diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index 8a0dfa3b2f..21895181cb 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -140,6 +140,15 @@ void wxDecToHex(int dec, wxChar *buf) buf[2] = 0; } +// Convert decimal integer to 2 characters +void wxDecToHex(int dec, char* ch1, char* ch2) +{ + int firstDigit = (int)(dec/16.0); + int secondDigit = (int)(dec - (firstDigit*16.0)); + (*ch1) = (char) hexArray[firstDigit]; + (*ch2) = (char) hexArray[secondDigit]; +} + // Convert decimal integer to 2-character hex string wxString wxDecToHex(int dec) { @@ -821,7 +830,7 @@ bool wxLaunchDefaultBrowser(const wxString& urlOrig, int flags) wxLogDebug(wxT("ICStart error %d"), (int) err); return false; } -#else +#else // (non-Mac, non-MSW) #ifdef __UNIX__ diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index 40c6c9e7b7..b77bca81bf 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -8170,18 +8170,6 @@ bool wxRichTextImageBlock::Load(wxImage& image) return success; } -// Array used in DecToHex conversion routine. -static char hexArray[] = "0123456789ABCDEF"; - -// Convert decimal integer to 2-character hex string -inline void wxRichTextDecToHex(int dec, char* buf) -{ - int firstDigit = (int)(dec/16.0); - int secondDigit = (int)(dec - (firstDigit*16.0)); - buf[0] = hexArray[firstDigit]; - buf[1] = hexArray[secondDigit]; -} - // Write data in hex to a stream bool wxRichTextImageBlock::WriteHex(wxOutputStream& stream) { @@ -8205,7 +8193,7 @@ bool wxRichTextImageBlock::WriteHex(wxOutputStream& stream) char* b = buf; for (i = 0; i < (n/2); i++) { - wxRichTextDecToHex(m_data[j], b); + wxDecToHex(m_data[j], b, b+1); b += 2; j ++; }