Announcement

Collapse
No announcement yet.

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.

    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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      52 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      71 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      38 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      99 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      60 views
      0 likes
      Last Post PaulMohn  
      Working...
      X