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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:49:50+00:00 2026-05-22T15:49:50+00:00

Basically I’m making an animated UI from scratch. Everything on the UI is derived

  • 0

Basically I’m making an animated UI from scratch. Everything on the UI is derived from a ScreenThing base class which can store a bitmap used to draw that thing, as well as its position. When I want to draw the UI I create a new blank Bitmap of the right size, create a Graphics object from that bitmap, then pass that Graphics object to all of the ScreenThings Draw() method to draw themselves. When that’s done, I print the bitmap to the screen with a PictureBox control.

This all works great, but it’s too slow. I want this to happen at least 30 times per second so the animation is smooth, but it’s taking more than 33 milliseconds for all of this to happen. I’ve seen that the reason for this slowness is the locking and unlocking of the bitmap memory. I’ve tried some code I found online that unlocks the bitmaps and makes a new GetPixel and SetPixel function and tried combining the images pixel by pixel like below, but this took even longer. (code below was just a test, it doesn’t place the image in the right place)

for (int i = 0; i < images.Count; i++)
{
    FastBitmap foreground = new FastBitmap(images[i]);
    foreground.LockImage();

    for (int x = 0; x < images[0].Width; x++)
    {
        for (int y = 0; y < images[0].Height; y++)
        {
            output.SetPixel(x, y, foreground.GetPixel(x, y));
        }
    }

    foreground.UnlockImage();
}

So what’s the best way to do this? Is it possible to use C# to draw a pretty big image (like 1024×768) in real time like this? If all else fails, I guess I could figure out a way to only draw the parts that have changed, but I’d love to avoid doing that if a brute force redraw of everything is possible. Thanks a lot!

  • 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-22T15:49:50+00:00Added an answer on May 22, 2026 at 3:49 pm

    Using bitmaps to draw real-time animations is very inefficient. Insted, create a CustomControl, and override its OnPaint method like this:

    protected override void OnPaint(PaintEventArgs pe)
    {
    }
    

    there you can use pe.Graphics to do any drawing you want and no copying to screen is required.
    I’ve used it and if you’re drawing routines are reasonably fast, that will be smooth.

    Also, remember to call SetStyle(ControlStyles.OptimizedDoubleBuffer, true); in the control constructor to get double buffering

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

Sidebar

Related Questions

Basically, I would like a brief explanation of how I can access a SQL
Basically I am trying to restart a service from a php web page. Here
Basically, so far I've just got an add and minus button which will change
Basically, i want my site to aggregate a lot of rss feeds and store
Basically, I have a matrix class like this (with a lot of operator overloads
Basically, I need to adjust the font type everywhere it isn't specified. How can
Basically what I want to do it this: a pdb file contains a location
Basically, something better than this: <input type=file name=myfile size=50> First of all, the browse
Basically I have some code to check a specific directory to see if an
Basically I'm going to go a bit broad here and ask a few questions

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.