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 kinfxhk, 07-13-2026, 10:18 AM
        0 responses
        28 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 07-13-2026, 09:50 AM
        0 responses
        17 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 07-13-2026, 07:21 AM
        0 responses
        26 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 07-11-2026, 02:11 AM
        0 responses
        24 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by SalmaTrader, 07-07-2026, 10:26 PM
        0 responses
        139 views
        0 likes
        Last Post SalmaTrader  
        Working...
        X