我有一个图案图像,需要使用 cairomm
在我的 Gtk::DrawingArea
中重复。
我尝试使用 Cairo::ImageSource
但没有运气。
最佳答案
使用 Cairo::Pattern
类很容易:
bool MyDrawingArea::on_draw(const Cairo::RefPtr<Cairo::Context> &cr) {
Cairo::RefPtr<Cairo::Pattern> image = Cairo::SurfacePattern::create(Cairo::ImageSurface::create_from_png("my_bg_pattern.png"));
image_->set_extend(Cairo::EXTEND_REPEAT); // THIS IS THE IMPORTANT BIT!
cr->set_source(image);
cr->paint();
}
关于c++ - 如何使用 cairomm 重复模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34230845/