Solved

Fast way to change alpha of LinearGradientBrush

Posted on 2009-04-09
2
438 Views
Last Modified: 2013-12-17

Hey, is there a fast (i.e., no for loops, and doesn't cause delay if used in a paint function) way to change the alpha of a LinearGradientBrush, i.e., filling in this function:

Thanks.


Friend Function MakeTranslucentGradientBrushForeColor(ByVal brsh As LinearGradientBrush) As LinearGradientBrush
 

        If m_Alpha = 255 Then

            Return brsh

        Else

            Dim rtn As LinearGradientBrush

...   magic code to change alpha or make new brush with changed alpha
 

            Return brsh
 

        End If
 

    End Function

Open in new window

0
Comment
Question by:riceman0
2 Comments
 
LVL 15

Accepted Solution

by:
oobayly earned 500 total points
ID: 24115089
Can you explain which colours you are having to change, the LinearColors array, or the InterpolationColors.Colors array?
If it's the former, you're only changing 2 colors.

Just running some basic code to set the alpha value for an array of 141 colours (The number of named colours in the Color struct), and timing it resulted in a elapsed time of 0ms. And that was running in debug mode.

Any chance you can post what code you're using to generate the LinearGradientBrush, and what properties in the brush you wish to change?
0
 

Author Comment

by:riceman0
ID: 24118943
It was a malformed question, what I was trying was working but something else was wrong. Points awarded for effort, thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now