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 Shansen, 08-30-2019, 10:18 PM
      24 responses
      938 views
      0 likes
      Last Post spwizard  
      Started by Max238, Today, 01:28 AM
      0 responses
      3 views
      0 likes
      Last Post Max238
      by Max238
       
      Started by rocketman7, Today, 01:00 AM
      0 responses
      2 views
      0 likes
      Last Post rocketman7  
      Started by wzgy0920, 04-20-2024, 06:09 PM
      2 responses
      27 views
      0 likes
      Last Post wzgy0920  
      Started by wzgy0920, 02-22-2024, 01:11 AM
      5 responses
      32 views
      0 likes
      Last Post wzgy0920  
      Working...
      X