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 RubenCazorla, Today, 09:07 AM
      2 responses
      13 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by i019945nj, 12-14-2023, 06:41 AM
      7 responses
      82 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by timmbbo, 07-05-2023, 10:21 PM
      4 responses
      158 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by tkaboris, Today, 08:01 AM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by Lumbeezl, 01-11-2022, 06:50 PM
      31 responses
      820 views
      1 like
      Last Post NinjaTrader_Adrian  
      Working...
      X