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 system that has been working fine in testing but now that
I have my php app working fine, performing some other Graph API functions. However,
I have some UIPopoverController that were working fine in 4.3/5.0 iOS iPad. Now, with
I have web service urls that were working fine and are now returning the
I have a site setup that is working fine in ie8 and firefox but
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 jqgrid with inline editing working fine, my requirement is that i
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.