Logo Search packages:      
Sourcecode: codeblocks version File versions  Download package

wxMemoryOutputStream * wxPdfParser::ASCIIHexDecode ( wxMemoryOutputStream *  osIn  )  [protected]

Decode a stream that has the ASCIIHexDecode filter.

Parameters:
osIn the input data
Returns:
the decoded data

Definition at line 50 of file pdfdecode.cpp.

References wxPdfTokenizer::GetHex(), and wxPdfTokenizer::IsWhitespace().

Referenced by GetStreamBytes().

{
  wxMemoryInputStream in(*osIn);
  wxMemoryOutputStream* osOut = new wxMemoryOutputStream();
  size_t inLength = in.GetSize();
  size_t k;
  bool first = true;
  int n1 = 0;
  for (k = 0; k < inLength; ++k)
  {
    int ch = in.GetC() & 0xff;
    if (ch == '>')
      break;
    if (wxPdfTokenizer::IsWhitespace(ch))
      continue;
    int n = wxPdfTokenizer::GetHex(ch);
    if (n == -1)
    {
      wxLogError(_T("wxPdfParser::ASCIIHexDecode: Illegal character."));
      osOut->Close();
      delete osOut;
      return NULL;
    }
    if (first)
    {
      n1 = n;
    }
    else
    {
      osOut->PutC((char)(((n1 << 4) + n) & 0xff));
    }
    first = !first;
  }
  if (!first)
  {
    osOut->PutC((char)((n1 << 4) & 0xff));
  }
  osOut->Close();
  return osOut;
}


Generated by  Doxygen 1.6.0   Back to index