Talguy 0 Junior Poster in Training

So I can crop an image in cariomm and display it to the canvas, but what I want to do is crop the image and save the cropped image to a Cairo::ImageSurface so that I can paint just the section of the overall image to the screen with out have to recrop the image all the time. Below is the code that I use to crop the image and paint it to the screen.

Cairo::RefPtr<Cairo::Context> context;
Cairo::RefPtr< Cairo::ImageSurface > image_surface_ptr_  = Cairo::ImageSurface::create_from_png("image.png");

context->save();
context->set_source (image_surface_ptr_, 0.0, 0.0);
context->rectangle (0.0, 0.0, somewidth, someheight);
context->clip();
context->paint();
context->restore();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.