void PageInfo::DecodeText(GP<ByteStream> pTextStream) { if (pTextStream == NULL) return; pTextStream->seek(0); GP<DjVuText> pDjVuText = DjVuText::create(); pDjVuText->decode(pTextStream); pText = pDjVuText->txt; bTextDecoded = true; }
void display(const GURL &url) { DjVuDumpHelper helper; GP<ByteStream> ibs = ByteStream::create(url, "rb"); GP<ByteStream> obs = helper.dump(ibs); GUTF8String str; size_t size = obs->size(); char *buf = str.getbuf(obs->size()); obs->seek(0); obs->readall(buf, size); GNativeString ns = str; fputs((const char*)ns, outputf); }
void lt_XMLParser::Impl::ChangeText( const int width, const int height, DjVuFile &dfile, const lt_XMLTags &tags ) { dfile.resume_decode(true); GP<DjVuText> text = DjVuText::create(); GP<DjVuTXT> txt = text->txt = DjVuTXT::create(); // to store the new text GP<ByteStream> textbs = ByteStream::create(); GP<DjVuInfo> info=(dfile.info); if(info) { const int h=info->height; const int w=info->width; txt->page_zone.text_start = 0; DjVuTXT::Zone &parent=txt->page_zone; parent.rect.xmin=0; parent.rect.ymin=0; parent.rect.ymax=h; parent.rect.xmax=w; double ws=1.0; if(width && width != w) { ws=((double)w)/((double)width); } double hs=1.0; if(height && height != h) { hs=((double)h)/((double)height); } make_child_layer(parent, tags, *textbs, h, ws,hs); textbs->write8(0); long len = textbs->tell(); txt->page_zone.text_length = len; textbs->seek(0,SEEK_SET); textbs->read(txt->textUTF8.getbuf(len), len); dfile.change_text(txt,false); } }
void analyze_incl_chunk(const GURL &url) { GP<ByteStream> gbs = ByteStream::create(url,"rb"); char buffer[24]; memset(buffer, 0, sizeof(buffer)); gbs->read(buffer,sizeof(buffer)); char *s = buffer; if (!strncmp(s, "AT&T", 4)) s += 4; if (strncmp(s, "FORM", 4) || strncmp(s+8, "DJVI", 4)) G_THROW("Expecting a valid FORM:DJVI chunk in the included file"); gbs->seek(0); GP<IFFByteStream> giff=IFFByteStream::create(gbs); GUTF8String chkid; giff->get_chunk(chkid); // FORM:DJVI for(; giff->get_chunk(chkid); giff->close_chunk()) if (chkid=="Djbz") analyze_djbz_chunk(giff->get_bytestream()); }
void PageInfo::DecodeAnno(GP<ByteStream> pAnnoStream) { if (pAnnoStream == NULL) return; pAnnoStream->seek(0); GP<DjVuAnno> pDjVuAnno = DjVuAnno::create(); pDjVuAnno->decode(pAnnoStream); pAnt = pDjVuAnno->ant; if (pAnt != NULL) { for (GPosition pos = pAnt->map_areas; pos; ++pos) { GP<GMapArea> pArea = pAnt->map_areas[pos]; anno.push_back(Annotation()); anno.back().Init(pArea, szPage, nInitialRotate); } } bAnnoDecoded = true; }