Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6607681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:31:45+00:00 2026-05-25T19:31:45+00:00

I have a fine, working system in C# that draws with Cairo commands in

  • 0

I have a fine, working system in C# that draws with Cairo commands in a render method. However, sometimes I would like to draw into a pixmap, rather than dynamically when the screen needs to be updated. For example, currently I have:

public override void render(Cairo.Context g) {
  g.Save();
  g.Translate(x, y);
  g.Rotate(_rotation);
  g.Scale(_scaleFactor, _scaleFactor);
  g.Scale(1.0, ((double)_yRadius)/((double)_xRadius));
  g.LineWidth = border;
  g.Arc(x1, y2, _xRadius, 0.0, 2.0 * Math.PI); 
  g.ClosePath();
}

But I would like, if I choose, to render the Cairo commands to a Gtk.Pixbuf. Something like:

 g = GetContextFromPixbuf(pixbuf);
 render(g);

Is that possible? It would be great if I didn’t have to turn the context back into a pixbuf, but that the cairo drawing would go directly to the pixbuf. Any hints on this would be appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:31:46+00:00Added an answer on May 25, 2026 at 7:31 pm

    The answer is actually quite easy: when you render the objects, render them to a context created from a saved surface. Then when you render the window, insert a context based on the same saved surface.

    Create a surface:

      surface = new Cairo.ImageSurface(Cairo.Format.Argb32, width, height);
    

    Render a shape to the surface:

    using (Cairo.Context g = new Cairo.Context(surface)) {
      shape.render(g); // Cairo drawing commands
    }
    

    Render the window:

      g.Save();
      g.SetSourceSurface(surface, 0, 0);
      g.Paint();
      g.Restore();
          ... // other Cairo drawing commands
    

    That’s it!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jQuery statement that's working fine. How would I re-write it in
I have a XAML MenuItem DataBound ItemsSource that is working fine however there is
I have this code that is working fine for me: using System; using System.Collections.Generic;
I have a web service that is working fine in one environment but not
I have a site setup that is working fine in ie8 and firefox but
I have an ASP.NET 2.0 application that is working fine in our local environment.
I have a page that's working fine in Firefox 3.5.6 but not in IE
im working on a content management system for that i have to download a
I have a query that is working fine on my local but when placed
I have a vs2010 c# solution that was working fine yesterday. When I try

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.