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 llanqui, Today, 03:53 AM
        0 responses
        2 views
        0 likes
        Last Post llanqui
        by llanqui
         
        Started by burtoninlondon, Today, 12:38 AM
        0 responses
        10 views
        0 likes
        Last Post burtoninlondon  
        Started by AaronKoRn, Yesterday, 09:49 PM
        0 responses
        14 views
        0 likes
        Last Post AaronKoRn  
        Started by carnitron, Yesterday, 08:42 PM
        0 responses
        11 views
        0 likes
        Last Post carnitron  
        Started by strategist007, Yesterday, 07:51 PM
        0 responses
        14 views
        0 likes
        Last Post strategist007  
        Working...
        X