void create_fgbz_chunk(IFFByteStream &iff) { int nzones = g().colorzones.size(); int npalette = g().colorpalette->size() / 3; GP<DjVuPalette> pal = DjVuPalette::create(); g().colorpalette->seek(0); pal->decode_rgb_entries(*g().colorpalette, npalette); pal->colordata.resize(0,blit_count-1); for (int d=0; d<blit_count; d++) { JB2Blit *blit = g().stencil->get_blit(d); const JB2Shape &shape = g().stencil->get_shape(blit->shapeno); GRect brect(blit->left, blit->bottom, shape.bits->columns(), shape.bits->rows()); int index = nzones; for (int i=0; i<nzones; i++) { GRect zrect = g().colorzones[i]; if (zrect.isempty() || zrect.intersect(brect, zrect)) index = i; } if (index >= npalette) G_THROW("create_fgbz_chunk: internal error"); pal->colordata[d] = index; } iff.put_chunk("FGbz"); pal->encode(iff.get_bytestream()); iff.close_chunk(); }
// -- Creates a JB2Image with the remaining components GP<JB2Image> CCImage::get_jb2image() const { GP<JB2Image> jimg = JB2Image::create(); jimg->set_dimension(width, height); if (runs.hbound() < 0) return jimg; if (ccs.hbound() < 0) G_THROW("Must first perform a cc analysis"); // Iterate over CCs for (int ccid=0; ccid<=ccs.hbound(); ccid++) { JB2Shape shape; JB2Blit blit; shape.parent = -1; shape.bits = get_bitmap_for_cc(ccid); shape.userdata = 0; if (ccid >= nregularccs) shape.userdata |= JB2SHAPE_SPECIAL; blit.shapeno = jimg->add_shape(shape); blit.left = ccs[ccid].bb.xmin; blit.bottom = ccs[ccid].bb.ymin; jimg->add_blit(blit); shape.bits->compress(); } // Return return jimg; }
void GIFFManager::load_chunk(IFFByteStream & istr, GP<GIFFChunk> chunk) { DEBUG_MSG("GIFFManager::load_chunk(): loading contents of chunk '" << chunk->get_name() << "'\n"); DEBUG_MAKE_INDENT(3); int chunk_size; GUTF8String chunk_id; while ((chunk_size=istr.get_chunk(chunk_id))) { if (istr.check_id(chunk_id)) { GP<GIFFChunk> ch=GIFFChunk::create(chunk_id); load_chunk(istr, ch); chunk->add_chunk(ch); } else { TArray<char> data(chunk_size-1); istr.get_bytestream()->readall( (char*)data, data.size()); GP<GIFFChunk> ch=GIFFChunk::create(chunk_id, data); chunk->add_chunk(ch); } istr.close_chunk(); } }
GP<JB2Image> erode8(const JB2Image *im) { int i; GP<JB2Image> newim = JB2Image::create(); newim->set_dimension(im->get_width(),im->get_height()); for(i=0; i<im->get_shape_count(); i++) { const JB2Shape &shape = im->get_shape(i); JB2Shape newshape; newshape.parent = shape.parent; if (shape.bits) newshape.bits = erode8(shape.bits); else newshape.bits = 0; newim->add_shape(newshape); } for(i=0; i<im->get_blit_count(); i++) { const JB2Blit* blit = im->get_blit(i); JB2Blit newblit; newblit.bottom = blit->bottom + 1; newblit.left = blit->left + 1; newblit.shapeno = blit->shapeno; newim->add_blit(newblit); } return newim; }
static void display_fgbz(ByteStream & out_str, IFFByteStream &iff, GUTF8String, size_t, DjVmInfo&, int) { GP<ByteStream> gbs = iff.get_bytestream(); int version = gbs->read8(); int size = gbs->read16(); out_str.format( "JB2 colors data, v%d, %d colors", version & 0x7f, size); }
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 MapRect::ma_drawInactive(const GRect & pm_rect, const GP<GPixmap> & pm) // pm_rect is the rectangle of the pane in screen coordinates // where pm is supposed to go to { if (mapper && pm) { GRect border_rect=gmap_area->get_bound_rect(); mapper->map(border_rect); GRect irect; if (irect.intersect(border_rect, pm_rect)) { // Translate the intersection into the GPixmap's coordinate irect.translate(-pm_rect.xmin, -pm_rect.ymin); // Do hiliting first if (gmap_area->hilite_color!=0xffffffff) { if (gmap_area->hilite_color==0xff000000) { // Do XOR hiliting for(int y=irect.ymin;y<irect.ymax;y++) { GPixel * pix=(*pm)[pm->rows()-1-y]+irect.xmin; for(int x=irect.xmin;x<irect.xmax;x++, pix++) { pix->r^=0xff; pix->g^=0xff; pix->b^=0xff; } } } else { // Do COLOR hiliting int r=(gmap_area->hilite_color & 0xff0000) >> (16+2); int g=(gmap_area->hilite_color & 0xff00) >> (8+2); int b=(gmap_area->hilite_color & 0xff) >> 2; for(int y=irect.ymin;y<irect.ymax;y++) { GPixel * pix=(*pm)[pm->rows()-1-y]+irect.xmin; for(int x=irect.xmin;x<irect.xmax;x++, pix++) { pix->r=((((int) pix->r << 1)+(int) pix->r) >> 2)+r; pix->g=((((int) pix->g << 1)+(int) pix->g) >> 2)+g; pix->b=((((int) pix->b << 1)+(int) pix->b) >> 2)+b; } } } } }
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); }
static void display_djvm_dirm(ByteStream & out_str, IFFByteStream & iff, GUTF8String head, size_t, DjVmInfo& djvminfo, int) { GP<DjVmDir> dir = DjVmDir::create(); dir->decode(iff.get_bytestream()); GPList<DjVmDir::File> list = dir->get_files_list(); if (dir->is_indirect()) { out_str.format( "Document directory (indirect, %d files %d pages)", dir->get_files_num(), dir->get_pages_num()); for (GPosition p=list; p; ++p) out_str.format( "\n%s%s -> %s", (const char*)head, (const char*)list[p]->get_load_name(), (const char*)list[p]->get_save_name() ); } else { out_str.format( "Document directory (bundled, %d files %d pages)", dir->get_files_num(), dir->get_pages_num()); djvminfo.dir = dir; djvminfo.map.empty(); for (GPosition p=list; p; ++p) djvminfo.map[list[p]->offset] = list[p]; } }
static void display_chunks(ByteStream & out_str, IFFByteStream &iff, const GUTF8String &head, DjVmInfo djvminfo) { size_t size; GUTF8String id, fullid; GUTF8String head2 = head + " "; GPMap<int,DjVmDir::File> djvmmap; int rawoffset; GMap<GUTF8String, int> counters; while ((size = iff.get_chunk(id, &rawoffset))) { if (!counters.contains(id)) counters[id]=0; else counters[id]++; GUTF8String msg; msg.format("%s%s [%d] ", (const char *)head, (const char *)id, size); out_str.format( "%s", (const char *)msg); // Display DJVM is when adequate if (djvminfo.dir) { GP<DjVmDir::File> rec = djvminfo.map[rawoffset]; if (rec) { GUTF8String id = rec->get_load_name(); GUTF8String title = rec->get_title(); out_str.format( "{%s}", (const char*) id); if (rec->is_include()) out_str.format(" [I]"); if (rec->is_thumbnails()) out_str.format(" [T]"); if (rec->is_shared_anno()) out_str.format(" [S]"); if (rec->is_page()) out_str.format(" [P%d]", rec->get_page_num()+1); if (id != title) out_str.format(" (%s)", (const char*)title); } } // Test chunk type iff.full_id(fullid); for (int i=0; disproutines[i].id; i++) if (fullid == disproutines[i].id || id == disproutines[i].id) { int n = msg.length(); while (n++ < 14+(int) head.length()) putchar(out_str, ' '); if (!iff.composite()) out_str.format( " "); (*disproutines[i].subr)(out_str, iff, head2, size, djvminfo, counters[id]); break; } // Default display of composite chunk out_str.format( "\n"); if (iff.composite()) display_chunks(out_str, iff, head2, djvminfo); // Terminate iff.close_chunk(); } }
void DjVuSource::ReadAnnotations(GP<ByteStream> pInclStream, set<GUTF8String>& processed, GP<ByteStream> pAnnoStream) { // Look for shared annotations GUTF8String strInclude; char buf[1024]; int nLength; while ((nLength = pInclStream->read(buf, 1024))) strInclude += GUTF8String(buf, nLength); // Eat '\n' in the beginning and at the end while (strInclude.length() > 0 && strInclude[0] == '\n') strInclude = strInclude.substr(1, static_cast<unsigned int>(-1)); while (strInclude.length() > 0 && strInclude[static_cast<int>(strInclude.length()) - 1] == '\n') strInclude.setat(strInclude.length() - 1, 0); if (strInclude.length() > 0 && processed.find(strInclude) == processed.end()) { processed.insert(strInclude); GURL urlInclude = m_pDjVuDoc->id_to_url(strInclude); GP<DataPool> pool = m_pDjVuDoc->request_data(NULL, urlInclude); GP<ByteStream> stream = pool->get_stream(); GP<IFFByteStream> iff(IFFByteStream::create(stream)); // Check file format GUTF8String chkid; if (!iff->get_chunk(chkid) || (chkid != "FORM:DJVI" && chkid != "FORM:DJVU" && chkid != "FORM:PM44" && chkid != "FORM:BM44")) { return; } // Find chunk with page info while (iff->get_chunk(chkid) != 0) { GP<ByteStream> chunk_stream = iff->get_bytestream(); if (chkid == "INCL") { ReadAnnotations(pInclStream, processed, pAnnoStream); } else if (chkid == "FORM:ANNO") { pAnnoStream->copy(*chunk_stream); } else if (chkid == "ANTa" || chkid == "ANTz") { const GP<IFFByteStream> iffout = IFFByteStream::create(pAnnoStream); iffout->put_chunk(chkid); iffout->copy(*chunk_stream); iffout->close_chunk(); } iff->seek_close_chunk(); } } }
void JB2Dict::set_inherited_dict(const GP<JB2Dict> &dict) { if (shapes.size() > 0) G_THROW( ERR_MSG("JB2Image.cant_set") ); if (inherited_dict) G_THROW( ERR_MSG("JB2Image.cant_change") ); inherited_dict = dict; inherited_shapes = dict->get_shape_count(); // Make sure that inherited bitmaps are marked as shared for (int i=0; i<inherited_shapes; i++) { JB2Shape &jshp = dict->get_shape(i); if (jshp.bits) jshp.bits->share(); } }
void DjVuFileCache::add_file(const GP<DjVuFile> & file) { DEBUG_MSG("DjVuFileCache::add_file(): trying to add a new item\n"); DEBUG_MAKE_INDENT(3); GCriticalSectionLock lock(&class_lock); // See if the file is already cached GPosition pos; for(pos=list;pos;++pos) if (list[pos]->get_file()==file) break; if (pos) list[pos]->refresh(); // Refresh the timestamp else { // Doesn't exist in the list yet int _max_size=enabled ? max_size : 0; if (max_size<0) _max_size=max_size; int add_size=file->get_memory_usage(); if (_max_size>=0 && add_size>_max_size) { DEBUG_MSG("but this item is way too large => doing nothing\n"); return; } if (_max_size>=0) clear_to_size(_max_size-add_size); list.append(new Item(file)); cur_size+=add_size; file_added(file); } }
void GIFFChunk::add_chunk(const GP<GIFFChunk> & chunk, int position) { DEBUG_MSG("GIFFChunk::add_chunk(): Adding chunk to '" << get_name() << "' @ position=" << position << "\n"); DEBUG_MAKE_INDENT(3); if (!type.length()) { DEBUG_MSG("Converting the parent to FORM\n"); type="FORM"; } if (chunk->get_type()=="PROP") { DEBUG_MSG("Converting the parent to LIST\n"); type="LIST"; } GPosition pos; if (position>=0 && chunks.nth(position, pos)) { chunks.insert_before(pos, chunk); }else { chunks.append(chunk); } }
void lt_XMLParser::Impl::ChangeTextOCR( const GUTF8String &value, const int width, const int height, const GP<DjVuFile> &dfile) { if(value.length() && value.downcase() != "false") { const GP<ByteStream> bs=OCRcallback(value,DjVuImage::create(dfile)); if( bs && bs->size() ) { const GP<lt_XMLTags> tags(lt_XMLTags::create(bs)); ChangeText(width,height,*dfile,*tags); } } }
void MMRDecoder::init(GP<ByteStream> gbs, const bool striped) { rowsperstrip = (striped ? gbs->read16() : height); src = VLSource::create(gbs, striped); mrtable = VLTable::create(mrcodes, 7); btable = VLTable::create(bcodes, 13); wtable = VLTable::create(wcodes, 13); }
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); } }
GP<GBitmap> JB2Image::get_bitmap(int subsample, int align) const { if (width==0 || height==0) G_THROW( ERR_MSG("JB2Image.cant_create") ); int swidth = (width + subsample - 1) / subsample; int sheight = (height + subsample - 1) / subsample; int border = ((swidth + align - 1) & ~(align - 1)) - swidth; GP<GBitmap> bm = GBitmap::create(sheight, swidth, border); bm->set_grays(1+subsample*subsample); for (int blitno = 0; blitno < get_blit_count(); blitno++) { const JB2Blit *pblit = get_blit(blitno); const JB2Shape &pshape = get_shape(pblit->shapeno); if (pshape.bits) bm->blit(pshape.bits, pblit->left, pblit->bottom, subsample); } return bm; }
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 JB2Dict::JB2Codec::Decode::code_inherited_shape_count(JB2Dict &jim) { int size=CodeNum(0, BIGPOSITIVE, inherited_shape_count_dist); { GP<JB2Dict> dict = jim.get_inherited_dict(); if (!dict && size>0) { // Call callback function to obtain dictionary if (cbfunc) dict = (*cbfunc)(cbarg); if (dict) jim.set_inherited_dict(dict); } if (!dict && size>0) G_THROW( ERR_MSG("JB2Image.need_dict") ); if (dict && size!=dict->get_shape_count()) G_THROW( ERR_MSG("JB2Image.bad_dict") ); } }
static void display_iw4(ByteStream & out_str, IFFByteStream &iff, GUTF8String, size_t, DjVmInfo&, int) { GP<ByteStream> gbs = iff.get_bytestream(); unsigned char serial = gbs->read8(); unsigned char slices = gbs->read8(); out_str.format( "IW4 data #%d, %d slices", serial+1, slices); if (serial == 0) { unsigned char major = gbs->read8(); unsigned char minor = gbs->read8(); unsigned char xhi = gbs->read8(); unsigned char xlo = gbs->read8(); unsigned char yhi = gbs->read8(); unsigned char ylo = gbs->read8(); out_str.format( ", v%d.%d (%s), %dx%d", major & 0x7f, minor, (major & 0x80 ? "b&w" : "color"), (xhi<<8)+xlo, (yhi<<8)+ylo ); } }
GP<GBitmap> JB2Image::get_bitmap(const GRect &rect, int subsample, int align, int dispy) const { if (width==0 || height==0) G_THROW( ERR_MSG("JB2Image.cant_create") ); int rxmin = rect.xmin * subsample; int rymin = rect.ymin * subsample; int swidth = rect.width(); int sheight = rect.height(); int border = ((swidth + align - 1) & ~(align - 1)) - swidth; GP<GBitmap> bm = GBitmap::create(sheight, swidth, border); bm->set_grays(1+subsample*subsample); for (int blitno = 0; blitno < get_blit_count(); blitno++) { const JB2Blit *pblit = get_blit(blitno); const JB2Shape &pshape = get_shape(pblit->shapeno); if (pshape.bits) bm->blit(pshape.bits, pblit->left-rxmin, pblit->bottom-rymin+dispy, subsample); } return bm; }
void JB2Dict::JB2Codec::code_bitmap_by_cross_coding (GBitmap &bm, GP<GBitmap> &cbm, const int libno) { // Make sure bitmaps will not be disturbed GP<GBitmap> copycbm=GBitmap::create(); if (cbm->monitor()) { // Perform a copy when the bitmap is explicitely shared GMonitorLock lock2(cbm->monitor()); copycbm->init(*cbm); cbm = copycbm; } GMonitorLock lock1(bm.monitor()); // Center bitmaps const int cw = cbm->columns(); const int dw = bm.columns(); const int dh = bm.rows(); const LibRect &l = libinfo[libno]; const int xd2c = (dw/2 - dw + 1) - ((l.right - l.left + 1)/2 - l.right); const int yd2c = (dh/2 - dh + 1) - ((l.top - l.bottom + 1)/2 - l.top); // Ensure borders are adequate bm.minborder(2); cbm->minborder(2-xd2c); cbm->minborder(2+dw+xd2c-cw); // Initialize row pointers const int dy = dh - 1; const int cy = dy + yd2c; #ifndef NDEBUG bm.check_border(); cbm->check_border(); #endif code_bitmap_by_cross_coding (bm,*cbm, xd2c, dw, dy, cy, bm[dy+1], bm[dy], (*cbm)[cy+1] + xd2c, (*cbm)[cy ] + xd2c, (*cbm)[cy-1] + xd2c); }
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; }
QDNavGotoPage::QDNavGotoPage(GP<DjVuDocument> &doc, DjVuImage * dimg, QWidget * parent, const char * name) : QeDialog(parent, name, TRUE) { setCaption(tr("DjVu: Goto Page")); QWidget * start=startWidget(); // Create the menu QVBoxLayout * vlay=new QVBoxLayout(start, 10, 10); QHBoxLayout * hlay=new QHBoxLayout(10); vlay->addLayout(hlay); QLabel * label=new QLabel(tr("Goto page"), start, "goto_label"); hlay->addWidget(label); menu=new QComboBox(FALSE, start, "goto_menu"); menu->setInsertionPolicy(QComboBox::NoInsertion); hlay->addWidget(menu); // Create the buttons hlay=new QHBoxLayout(10); vlay->addLayout(hlay); hlay->addStretch(1); QPushButton * ok_butt=new QPushButton(tr("&OK"), start, "ok_butt"); ok_butt->setDefault(TRUE); hlay->addWidget(ok_butt); QPushButton * cancel_butt=new QPushButton(tr("&Cancel"), start, "cancel_butt"); hlay->addWidget(cancel_butt); // Set menu contents int pagenum = 0; int cur_page = doc->url_to_page(dimg->get_djvu_file()->get_url()); GPList<DjVmDir::File> lst = doc->get_djvm_dir()->get_files_list(); for (GPosition p=lst; p; ++p) { char buffer[64]; GP<DjVmDir::File> f = lst[p]; if (!f->is_page()) continue; ++pagenum; GNativeString id = f->get_load_name(); GNativeString title = f->get_title(); if (title != id) { menu->insertItem(QStringFromGString(title)); } else { sprintf(buffer, "%d", pagenum); menu->insertItem(buffer); } } menu->setCurrentItem(cur_page); // Connect signals connect(ok_butt, SIGNAL(clicked(void)), this, SLOT(accept(void))); connect(cancel_butt, SIGNAL(clicked(void)), this, SLOT(reject(void))); }
MapArea::MapArea(const GP<GMapArea> & area) : gmap_area(area) { pane=0; mapper=0; in_motion=false; enable_edit_controls=false; active_outline_mode=inactive_outline_mode=false; active=gmap_area->border_always_visible; force_always_active=false; createCursors(); GUTF8String str=area->check_object(); if (str.length()) G_THROW(str); }
GP<DjVuFile> lt_XMLParser::Impl::get_file(const GURL &url,GUTF8String id) { GP<DjVuFile> dfile; GP<DjVuDocument> doc; GCriticalSectionLock lock(&xmlparser_lock); { GPosition pos=m_docs.contains(url.get_string()); if(pos) { doc=m_docs[pos]; }else { doc=DjVuDocument::create_wait(url); if(! doc->wait_for_complete_init()) { G_THROW(( ERR_MSG("XMLAnno.fail_init") "\t")+url.get_string() ); } m_docs[url.get_string()]=doc; } if(id.is_int()) { const int xpage=id.toInt(); //atoi((char const *)page); if(xpage>0) id=doc->page_to_id(xpage-1); }else if(!id.length()) { id=doc->page_to_id(0); } } const GURL fileurl(doc->id_to_url(id)); GPosition dpos(m_files.contains(fileurl.get_string())); if(!dpos) { if(!doc->get_id_list().contains(id)) { G_THROW( ERR_MSG("XMLAnno.bad_page") ); } dfile=doc->get_djvu_file(id,false); if(!dfile) { G_THROW( ERR_MSG("XMLAnno.bad_page") ); } m_files[fileurl.get_string()]=dfile; }else { dfile=m_files[dpos]; } return dfile; }
// Looks up the msgID in the file of messages and returns a pointer to // the beginning of the translated message, if found; and an empty string // otherwise. void DjVuMessageLite::LookUpID( const GUTF8String &xmsgID, GUTF8String &message_text, GUTF8String &message_number ) const { if(!Map.isempty()) { GUTF8String msgID = xmsgID; #if HAS_CTRL_C_IN_ERR_MSG int start = 0; while (msgID[start] == '\003') start ++; if (start > 0) msgID = msgID.substr(start, msgID.length() - start); #endif GPosition pos=Map.contains(msgID); if(pos) { const GP<lt_XMLTags> tag=Map[pos]; GPosition valuepos=tag->get_args().contains(valuestring); if(valuepos) { message_text=tag->get_args()[valuepos]; }else { const GUTF8String raw(tag->get_raw()); const int start_line=raw.search((unsigned long)'\n',0); const int start_text=raw.nextNonSpace(0); const int end_text=raw.firstEndSpace(0); if(start_line<0 || start_text<0 || start_text < start_line) { message_text=raw.substr(0,end_text).fromEscaped(); }else { message_text=raw.substr(start_line+1,end_text-start_line-1).fromEscaped(); } } GPosition numberpos=tag->get_args().contains(numberstring); if(numberpos) { message_number=tag->get_args()[numberpos]; } } } }
void MapArea::draw(const GRect & bm_rect, const GP<GBitmap> & bm_in, GRect & pm_rect, GP<GPixmap> & pm_out, DRAW_MODE draw_mode) // Draws itself into the specified bitmap. The bm_rect should be // in the pane's coordinates. Since GBitmap may not contain color // information, we will create a color GPixmap patch (pm_out), where we // will actually be drawing. The pm_rect is a rectangle in // pane coordinates where this pm_out should go to. { DEBUG_MSG("MapArea::draw(): Highlighting " << gmap_area->url << ":" << gmap_area->target << "\n"); DEBUG_MAKE_INDENT(3); if (pane) { GRect brect=gmap_area->get_bound_rect(); mapper->map(brect); brect.inflate(3, 3); GRect irect; if (irect.intersect(bm_rect, brect)) { pm_rect=irect; irect.translate(-bm_rect.xmin, -bm_rect.ymin); pm_out=GPixmap::create(*bm_in, GRect(irect.xmin, bm_in->rows()-irect.ymax, irect.width(), irect.height())); if (!isInactiveOutlineMode()) if (draw_mode==DRAW_INACTIVE || draw_mode==DRAW_ACTIVE) ma_drawInactive(pm_rect, pm_out); if (!isActiveOutlineMode()) if (draw_mode==APPLY_ACTIVE || draw_mode==DRAW_ACTIVE) ma_applyActive(pm_rect, pm_out); } } }
void PageInfo::Update(GP<DjVuImage> pImage) { if (pImage == NULL) return; if (!bDecoded) { nInitialRotate = GetTotalRotate(pImage, 0); szPage = CSize(pImage->get_width(), pImage->get_height()); if (nInitialRotate % 2 != 0) swap(szPage.cx, szPage.cy); nDPI = pImage->get_dpi(); if (szPage.cx <= 0 || szPage.cy <= 0) { szPage.cx = 100; szPage.cy = 100; nDPI = 100; } bHasText = !!(pImage->get_djvu_file()->text != NULL); bDecoded = true; } try { if (bHasText && !bTextDecoded) DecodeText(pImage->get_text()); } catch (GException&) { } try { if (!bAnnoDecoded) DecodeAnno(pImage->get_anno()); } catch (GException&) { } }