bool keyi__(){ Glib::RefPtr<Gdk::Window> w = da_->get_window(); if(!w) return false; if(!cr_) return false; return true; }
void shuaxin__(){ Glib::RefPtr<Gdk::Window> w = da_->get_window(); if (w) { Gtk::Allocation a = da_->get_allocation(); Gdk::Rectangle r(0, 0,a.get_width(),a.get_height()); w->invalidate_rect(r, false); } }
void saveSnapshot(string path) { Gtk::DrawingArea* drawArea = 0; VRGuiBuilder()->get_widget("glarea", drawArea); Glib::RefPtr<Gdk::Drawable> src = drawArea->get_window(); int smin = min(drawArea->get_width(), drawArea->get_height()); int u = max(0.0, drawArea->get_width()*0.5 - smin*0.5); int v = max(0.0, drawArea->get_height()*0.5 - smin*0.5); Glib::RefPtr<Gdk::Pixbuf> pxb = Gdk::Pixbuf::create( src, u, v, smin, smin); pxb = pxb->scale_simple(128, 128, Gdk::INTERP_HYPER); pxb->save(path, "png"); }
OSG::ImageRecPtr takeSnapshot() { Gtk::DrawingArea* drawArea = 0; VRGuiBuilder()->get_widget("glarea", drawArea); Glib::RefPtr<Gdk::Drawable> src = drawArea->get_window(); // 24 bits per pixel ( src->get_depth() ) int w = drawArea->get_width(); int h = drawArea->get_height(); w -= w%4; h -= h%4; //cout << "PIC FORMAT " << w << " " << h << " " << src->get_depth() << endl; Glib::RefPtr<Gdk::Image> img = Glib::wrap( gdk_drawable_get_image(src->gobj(), 0, 0, w, h) ); Glib::RefPtr<Gdk::Pixbuf> pxb = Glib::wrap( gdk_pixbuf_get_from_image(NULL, img->gobj(), src->get_colormap()->gobj(), 0,0,0,0,w,h) ); OSG::ImageRecPtr res = OSG::Image::create(); //Image::set(pixFormat, width, height, depth, mipmapcount, framecount, framedelay, data, type, aloc, sidecount); res->set(OSG::Image::OSG_RGB_PF, w, h, 1, 0, 1, 0, (const unsigned char*)pxb->get_pixels(), OSG::Image::OSG_UINT8_IMAGEDATA, true, 1); return res; }
bool area___::expose_evt__(GdkEventExpose* event){ if(code_.size()>0){ Glib::RefPtr<Gdk::Window> window=da_->get_window(); if(window){ cr_ = window->create_cairo_context(); if(event){ cr_->rectangle(event->area.x, event->area.y, event->area.width, event->area.height); cr_->clip(); } #ifdef debug_ test__(); #else char buf[32]; l2s__((long)this,buf); d_(sh_,on_,code_.c_str(),NULL,3,ht_->name__(),"重绘",buf); #endif } return true; } return false; }
void huaju__(char*buf){ Glib::RefPtr<Gdk::Window> w = da_->get_window(); if (w) { cr_ = w->create_cairo_context(); } }