Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

SharpDX BitmapBrush in OnRender

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

    SharpDX BitmapBrush in OnRender

    I'm trying to use a SharpDX BitmapBrush to fill an ellipse in OnRender. The error I get is:
    "Chart rendering failed. There is likely a problem with a chart object's OnRender method. D2D error = 'HRESULT: [0x80070057], Module: [General], ApiCode: [E_INVALIDARG/Invalid Arguments], Message: The parameter is incorrect."
    in the log.

    If I use RenderTarget.DrawBitmap(), I can see the image and draw it on the chart - so the loading of the bitmap is not the problem.

    For example, trying to create a bitmap brush and fill a rectangle with it using the following code will reproduce the error:
    BitmapBrush bitmapBrush = new BitmapBrush(RenderTarget,myBitmap);
    SharpDX.RectangleF rect = new SharpDX.Rectangle(0,0,50,50);
    RenderTarget.FillRectangle(rect,bitmapBrush);
    Are bitmap brushes not possible - or am I missing something crucial, or an easier solution? I looked into ImageBrush as well. I just want to be able to fill and texture geometries on the chart with a loaded image file.
    Last edited by NicholasJoannette; 08-05-2021, 12:28 PM.

    #2
    Hello NicholasJoannette,

    Thank you for your post.

    The following works for me to create a bitmap brush and use it to fill an ellipse:

    Code:
    SharpDX.Direct2D1.BitmapBrush myBitmapBrush = new SharpDX.Direct2D1.BitmapBrush(RenderTarget, myBitmap);
    
    RenderTarget.FillEllipse(new SharpDX.Direct2D1.Ellipse(new SharpDX.Vector2((float)ChartPanel.W / 2, (float)ChartPanel.H / 2), 10, 10), myBitmapBrush);
    
    myBitmapBrush.Dispose();
    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Kate View Post
      Hello NicholasJoannette,

      Thank you for your post.

      The following works for me to create a bitmap brush and use it to fill an ellipse:

      Code:
      SharpDX.Direct2D1.BitmapBrush myBitmapBrush = new SharpDX.Direct2D1.BitmapBrush(RenderTarget, myBitmap);
      
      RenderTarget.FillEllipse(new SharpDX.Direct2D1.Ellipse(new SharpDX.Vector2((float)ChartPanel.W / 2, (float)ChartPanel.H / 2), 10, 10), myBitmapBrush);
      
      myBitmapBrush.Dispose();
      Please let us know if we may be of further assistance to you.
      Thanks so much for the help. I was actually making an error elsewhere. Very appreciated!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by agraham, Today, 01:05 PM
      0 responses
      25 views
      0 likes
      Last Post agraham
      by agraham
       
      Started by jagswe, Today, 01:34 PM
      0 responses
      13 views
      0 likes
      Last Post jagswe
      by jagswe
       
      Started by PaulMohn, Yesterday, 05:25 AM
      9 responses
      34 views
      0 likes
      Last Post NinjaTrader_PaulH  
      Started by srbdoc, Today, 12:20 PM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_ChristopherJ  
      Started by blar58, Today, 12:19 PM
      1 response
      19 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X