Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 455
  • Last Modified:

Fast way to change alpha of LinearGradientBrush


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
riceman0
Asked:
riceman0
1 Solution
 
oobaylyCommented:
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
 
riceman0Author Commented:
It was a malformed question, what I was trying was working but something else was wrong. Points awarded for effort, thanks.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now