Esempio n. 1
0
QImage* CReb::getPicture(const QString& ref)
{
  QMap<QString, UInt32>::Iterator iter = m_index.find(ref);
  if (iter != m_index.end())
    {
      unsuspend();
      Page_detail rs = m_pagedetails[iter.data()];
      char* imgbuffer = new char[rs.len];
      fseek(fin, page2pos(iter.data()), SEEK_SET);
      fread(imgbuffer, rs.len, 1, fin);
      QByteArray arr;
      arr.assign((const char*)imgbuffer, rs.len);
      QImage* qimage = new QImage(arr);
      return qimage;
    }
  else
    {
      return NULL;
    }
}
Esempio n. 2
0
bool XepParser::parse(QFile &f)
{
    char buf[4096];
    char XML_START[] = "<smiles>";
    XML_Parse(m_parser, XML_START, strlen(XML_START), false);
    unsigned start = 0;
    for (;;){
        char s32[] = "<32bit_Icons>";
        char e32[] = "</32bit_Icons>";
        int size = f.readBlock(&buf[start], sizeof(buf) - start);
        if (size <= 0)
            break;
        size += start;
        replace(buf, size, s32, "<AA");
        replace(buf, size, e32, "</AA");
        if (size == sizeof(buf)){
            start = strlen(e32);
            size -= start;
        }
        int res = XML_Parse(m_parser, buf, size, false);
        if (res != XML_STATUS_OK)
            return false;
        if (start)
            memmove(buf, &buf[sizeof(buf) - start], start);
    }
    if ((m_pict.size() == 0) || (m_width == 0) || (m_height == 0))
        return false;
	Buffer pict;
	pict.fromBase64(m_pict);
	if (pict.size() < 28)
		return false;
    QByteArray arr;
    arr.assign(pict.data(28), pict.size() - 28);
    QImage img(arr);
    if ((img.width() == 0) || (img.height() == 0))
        return false;
    m_image.convertFromImage(img);
    return true;
}