int GRect::recthull(const GRect &rect1, const GRect &rect2) { if (rect1.isempty()) { xmin = rect2.xmin; xmax = rect2.xmax; ymin = rect2.ymin; ymax = rect2.ymax; return !isempty(); } if (rect2.isempty()) { xmin = rect1.xmin; xmax = rect1.xmax; ymin = rect1.ymin; ymax = rect1.ymax; return !isempty(); } xmin = imin(rect1.xmin, rect2.xmin); xmax = imax(rect1.xmax, rect2.xmax); ymin = imin(rect1.ymin, rect2.ymin); ymax = imax(rect1.ymax, rect2.ymax); return 1; }
int operator==(const GRect & r1, const GRect & r2) { bool isempty1 = r1.isempty(); bool isempty2 = r2.isempty(); if (isempty1 || isempty2) if (isempty1 && isempty2) return 1; if ( r1.xmin==r2.xmin && r1.xmax==r2.xmax && r1.ymin==r2.ymin && r1.ymax==r2.ymax ) return 1; return 0; }
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(); }
void GRectMapper::set_output(const GRect &rect) { if (rect.isempty()) G_THROW( ERR_MSG("GRect.empty_rect2") ); rectTo = rect; rw = rh = GRatio(); }
void GRectMapper::set_input(const GRect &rect) { if (rect.isempty()) G_THROW( ERR_MSG("GRect.empty_rect1") ); rectFrom = rect; if (code & SWAPXY) { iswap(rectFrom.xmin, rectFrom.ymin); iswap(rectFrom.xmax, rectFrom.ymax); } rw = rh = GRatio(); }
void parse_color_zones(const char *s) { bool fullpage = false; int zones = 0; g().colorzones.empty(); g().colorpalette = ByteStream::create(); // zones while (s[0] == '#') { char rgb[3]; GRect rect; s = parse_color_name(s+1, rgb); if (s[0] == ':') { int c[4]; for (int i=0; i<4; i++) { char *e = 0; c[i] = strtol(s+1, &e, 10); if (e <= s || (i>=2 && c[i]<0) || (i<3 && e[0]!=',')) G_THROW("Invalid coordinates in FGbz chunk specification"); s = e; } rect = GRect(c[0],c[1],c[2],c[3]); } if (rect.isempty()) fullpage = true; g().colorpalette->writall(rgb, 3); g().colorzones.touch(zones); g().colorzones[zones] = rect; zones++; } if (s[0]) G_THROW("Syntax error in FGbz chunk specification"); // add extra black palette entry if (! fullpage) { char rgb[3] = {0,0,0}; g().colorpalette->writall(rgb, 3); } }
void QDBase::eraseMapAreas(bool search_results_too, bool allow_draw) { DEBUG_MSG("QDBase::eraseMapAreas(): Erasing the map areas\n"); DEBUG_MAKE_INDENT(3); GRect grect; grect.intersect(rectDocument, rectVisible); for(GPosition pos=map_areas;pos;) { GP<MapArea> ma=map_areas[pos]; if (search_results_too || ma->getComment()!=search_results_name) { GPosition this_pos=pos; ++pos; map_areas.del(this_pos); if (!grect.isempty() && allow_draw) ma->repaint(); } else ++pos; } cur_map_area=0; delete map_area_tip; map_area_tip=0; }