Solved

Fast way to change alpha of LinearGradientBrush

Posted on 2009-04-09
2
449 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…

751 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