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

  • Home
  • SEARCH
  • 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 75077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:27:35+00:00 2026-05-10T20:27:35+00:00

To get some smooth graphics, I want to draw oversampled by factor 2 and

  • 0

To get some smooth graphics, I want to draw oversampled by factor 2 and scale down afterwards.

So what I am doing is to draw oversampled on a wxBitmap in a wxMemoryDC, and then scale it down before copying to my dc. The code below works fine, but bitmapOversampled.ConvertToImage(); is extremely slow.

Is there any way to achieve the same without having to convert from wxBitmap to wxImage and vice versa?

     void OnPaint     ( wxPaintEvent& event )     {         wxBitmap bitmapOversampled(m_width * 2, m_height * 2);         wxMemoryDC memDC(bitmapOversampled);          // Draw the elements.         drawElements(&memDC);          // Scale to correct size.         wxImage image = bitmapOversampled.ConvertToImage();         image.Rescale(m_width, m_height);         memDC.SelectObject(wxBitmap(image));          // Copy to dc.         wxPaintDC dc(this);         dc.Blit(0, 0, m_width, m_height, &memDC, 0, 0);     }; 
  • 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. 2026-05-10T20:27:35+00:00Added an answer on May 10, 2026 at 8:27 pm

    Sadly, there is no portable wx method to do that scaling faster. But there is a Scale method in the Gtk port in wxBitmap. You can use that for wxGTK. For wxMSW, you can use StretchBlt of the win32 API. There are methods in wxDC that will provide you with the native HDC handle for Windows.

    You can make it somewhat more straight forward if you draw directly:

    wxPaintDC dc(this); dc.DrawBitmap(image, 0, 0, false); 

    Also, don’t recreate the bitmap in each paint event. Store it as a member, and recreate it only when you get a wxSizeEvent. It will probably considerably speed up your program.

    Another way is to drop the scaling altogether and use wxGraphicsContext. It uses Cairo on wxGTK, and gdi+ on wxMSW. It’s relatively new, but can draw antialiased.

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

Sidebar

Related Questions

Where can I get some decent looking free ASP.Net or CSS themes?
I am trying to get some accurate runtime comparisons of PHP vs Python (and
I need to get some information that is contained in the MFT on a
I am trying to get some XML data with LINQ, but running into a
I need to get some AVI animations for use with the Borland VCL TAnimate
I'm trying to get some code working that a previous developer has written. Yep,
Could I get some confirmations from the community that I'm not going mad, and
Can I get some constructive feedback about the following architecture? Simplified Architecture Summary: Return
Wanted to get some consensus around a UI feature I'm working on right now.
If I try the getting-started on http://flexmojos.sonatype.org/getting-started.html I get some errors. Can somebody help

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.