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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T09:39:33+00:00 2026-05-14T09:39:33+00:00

I have a application that uses the Aero glass effect, so each pixel has

  • 0

I have a application that uses the Aero glass effect, so each pixel has an alpha value in addition to red, green, and blue values. I have one custom-draw control that has a solid white background (alpha = 255). I would like to draw solid text on the control using the GDI text functions. However, these functions set the alpha value to an arbitrary value, causing the text to translucently show whatever window is beneath my application’s.

After calling rendering the text, I would like to go through all of the pixels in the control and set their alpha value back to 255. What’s the best way to do that?

I haven’t had any luck with the BitBlt, GetPixel, and SetPixel functions. They appear to be oblivious to the alpha value.

Here are other solutions that I have considered and rejected:

  • Draw to a bitmap, then copy the bitmap to the device: With this approach, the text rendering does not make use of the characteristics of the monitor (e.g., ClearText). If you know of a way to get GDI to render the text to the bitmap exactly as it would render to the screen, that would also solve my problem.
  • Use GDI+ for text rendering: This application originally used GDI+ for text rendering (before I started working on Aero support). I switched to GDI because of difficulties I encountered trying to accurately measure strings with GDI+. I’d rather not switch back.
  • Set the Aero region to avoid the control in question: My application’s window is actually a child window of a different application running in a different process. I don’t have direct control over the Aero settings on the top-level window.

The application is written in C# using Windows Forms, though I’m not above using Interop to call Win32 API functions.

  • 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-14T09:39:33+00:00Added an answer on May 14, 2026 at 9:39 am

    Below is the solution I eventually came up with. It’s kind of ugly and could probably be simplified, but it works. The idea is to create a BufferedGraphics object based on the original Graphics object (i.e., the screen). In the BufferedGraphics object, TextRenderer.DrawText() will render the text exactly like it would if it was drawing to the screen. I then create a regular graphics object, copy the Buffered Graphics object to the regular graphics object, and finally draw the regular graphics object to the screen.

    Rectangle inner = new Rectangle(Point.Empty, ContentRectangle.Size);
    using (BufferedGraphics bg = BufferedGraphicsManager.Current.Allocate(e.Graphics, inner)) {
        using (Bitmap bmp = new Bitmap(inner.Width, inner.Height, bg.Graphics)) {
            using (Graphics bmpg = Graphics.FromImage(bmp)) {
                bg.Graphics.Clear(BackColor);
                do_my_drawing(bg.Graphics);
                bg.Graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
                e.Graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
                bmpg.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
    
                bg.Render(bmpg);
                e.Graphics.DrawImageUnscaledAndClipped(bmp, ContentRectangle);
            }
        }
    }
    

    Setting all of the CompositingMode attributes probably isn’t necessary, but once I got it working I didn’t bother testing all the permutations to figure out which, if any, are needed.

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

Sidebar

Related Questions

I have an application that uses (has referenced) a class library (myLib.dll private assembly).
I have an application that uses NHibernate as its ORM and sometimes it experiences
I have client application that uses WCF service to insert some data to backend
I have an application that uses the accelerometer. Sometimes, the application will launch without
I have an application that uses window.open() to generate dynamic popups. Unfortunately, I've had
I have an application that uses a cron like job to update a set
We have an application that uses a dual monitor setup - User A will
I have an application that uses DataTables to perform grouping, filtering and aggregation of
I have an application that uses simple sockets to pass some characters between two
I have a Windows application that uses a .NET PropertyGrid control. Is it possible

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.