void IVGAMap::setMergePoint(int id, int merge_id) { if (id == -1) { return; } PixelRef pix; if (merge_id == -1) { pix = id; } else { pix = PixelRef(merge_id); } // you cannot just set the merge point, as this is associated with a merge line // so this piece of code sets up the merge for you properly: ((PointMap *)m_data)->mergePixels(id,pix); }
unsigned long bt::ColorCache::find(unsigned int screen, int r, int g, int b) { if (r < 0 && r > 255) r = 0; if (g < 0 && g > 255) g = 0; if (b < 0 && b > 255) b = 0; // see if we have allocated this color before RGB rgb(screen, r, g, b); Cache::iterator it = cache.find(rgb); if (it != cache.end()) { // found a cached color, use it ++it->second.count; #ifdef COLORCACHE_DEBUG fprintf(stderr, "bt::ColorCache: use %02x/%02x/%02x, count %4u\n", r, g, b, it->second.count); #endif // COLORCACHE_DEBUG return it->second.pixel; } XColor xcol; xcol.red = r | r << 8; xcol.green = g | g << 8; xcol.blue = b | b << 8; xcol.pixel = 0; xcol.flags = DoRed | DoGreen | DoBlue; Colormap colormap = _display.screenInfo(screen).colormap(); if (!XAllocColor(_display.XDisplay(), colormap, &xcol)) { fprintf(stderr, "bt::Color::pixel: cannot allocate color 'rgb:%02x/%02x/%02x'\n", r, g, b); xcol.pixel = BlackPixel(_display.XDisplay(), screen); } #ifdef COLORCACHE_DEBUG fprintf(stderr, "bt::ColorCache: add %02x/%02x/%02x, pixel %08lx\n", r, g, b, xcol.pixel); #endif // COLORCACHE_DEBUG cache.insert(CacheItem(rgb, PixelRef(xcol.pixel))); return xcol.pixel; }