Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SharpDX Color from RGB

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    SharpDX Color from RGB

    In NT7 I used the follow to set the transparency and color for my brushes, I can't find any documentation on how to do the same for a SharpDX.Direct2D1.Brush

    What would be the equivalent for a SharpDX Brush using the NT7 code below?
    Code:
    Color grayColor = Color.FromArgb(255,grayScale, grayScale, grayScale);
    Edit: Found this after a lot of searching

    Code:
    Brush grayColor = new SolidColorBrush(Color.FromArgb(255,grayScale, grayScale, grayScale));
    
    grayColor.ToDxBrush(RenderTarget)
    Last edited by habibalex; 10-18-2015, 05:23 PM.

    #2
    Hi,

    I had trouble when I didn't freeze brushes I created:

    You should probably do the same. It would be something like this:
    Code:
    Brush grayColor = new SolidColorBrush(Color.FromArgb(255,grayScale, grayScale, grayScale));
    
    grayColor.Freeze();
    
    grayColor.ToDxBrush(RenderTarget)
    This is due to the multiple threads NT8 uses...

    Comment


      #3
      So any brushes that I do not change after i set the color, it makes sense to use the Freeze() method, but what about in situations like in a for loop where I change the grayScale once per loop iteration?

      Comment


        #4
        Hello habibalex,

        In this instance you would not freeze the brush. In general I believe WPF will create a clone of the brush in a frozen state to render the content if you do not freeze the brush yourself. Freezing the brush yourself prevents this copying, but obviously you would not be able to do that if you were dynamically modifying its values.

        Please let me know if I may be of further assistance.
        Last edited by NinjaTrader_MichaelM; 10-19-2015, 07:04 AM.
        Michael M.NinjaTrader Quality Assurance

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by LiamTwine, Today, 08:10 AM
        0 responses
        2 views
        0 likes
        Last Post LiamTwine  
        Started by Balage0922, Today, 07:38 AM
        0 responses
        5 views
        0 likes
        Last Post Balage0922  
        Started by JoMoon2024, Today, 06:56 AM
        0 responses
        6 views
        0 likes
        Last Post JoMoon2024  
        Started by Haiasi, 04-25-2024, 06:53 PM
        2 responses
        19 views
        0 likes
        Last Post Massinisa  
        Started by Creamers, Today, 05:32 AM
        0 responses
        6 views
        0 likes
        Last Post Creamers  
        Working...
        X