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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        666 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        377 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        110 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        575 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        580 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X