Solved

Fast way to change alpha of LinearGradientBrush

Posted on 2009-04-09
2
444 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to read text with RegEx... 2 25
SSIS On fail action 5 38
Import MySQL data into MS Access using VB.Net interface 5 29
System.net.Sockets Error 5 26
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
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 …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

860 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