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 7596943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:02:42+00:00 2026-05-30T22:02:42+00:00

Hopefully this’ll be a fairly simple answer, but it’s not the easiest thing to

  • 0

Hopefully this’ll be a fairly simple answer, but it’s not the easiest thing to google for.

I’m planning to do a lot of painting using simple shapes, but the actual result doesn’t need to be displayed to the user until the final stage, so for the sake of speed, I was wondering if there were existing methods in c#/WPF to draw simple shapes to a buffer without the overhead of a BitmapSource, so at the end I can just copy it into a WritableBitmap.

Something like

PixelFormat pixelFormat = PixelFormats.Default;
int stride = bitmapWidth * pixelFormat.BitsPerPixel / 8;
byte[] pixels new byte[bitmapHeight * stride];
*some static library*.DrawOval(xpos=10,ypos=10,radius=5, pixels, stride, pixelFormat);

Thanks

  • 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-30T22:02:44+00:00Added an answer on May 30, 2026 at 10:02 pm

    “Drawing shapes to a buffer” in WPF could be done by drawing shapes into a DrawingVisual using a DrawingContext. When drawing is finished, the DrawingVisual can be rendered into a RenderTargetBitmap.

    Example:

    DrawingVisual drawingVisual = new DrawingVisual();
    
    using (DrawingContext drawingContext = drawingVisual.RenderOpen())
    {
        drawingContext.DrawEllipse(null, new Pen(Brushes.Black, 1), new Point(100, 100), 50, 50);
    }
    
    Drawing drawing = drawingVisual.Drawing;
    
    using (DrawingContext drawingContext = drawingVisual.RenderOpen())
    {
        drawingContext.DrawDrawing(drawing);
        drawingContext.DrawEllipse(null, new Pen(Brushes.Black, 1), new Point(100, 100), 60, 60);
    }
    
    RenderTargetBitmap bitmap = new RenderTargetBitmap(200, 200, 96, 96, PixelFormats.Default);
    bitmap.Render(drawingVisual);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hopefully this doesn't sound ridiculous, but are some parts of the web.config not required
Hopefully this question has a simple answer i'm overlooking! I have an IIS webserver
Hopefully this is a pretty simple question for someone to answer. I have a
Hopefully this question is not to confusing, but I can help clear it up
Hopefully this is a quickie: I've been doing a lot of Java/Google Web Toolkit
Hopefully this won't be too difficult, but I'm not too skilled in regular expressions.
Hopefully this isn't a repeat, but there are 5000+ questions here with not all
Hopefully this is a simple one, but can anyone provide some simple c# code
Hopefully this is something simple but what i am trying to do is only
Hopefully this is simple. I have a fairly simple ASP.NET (framework version 2) app

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.