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

NT8 SuperDom column - cache rectangles to bitmapimage

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

    NT8 SuperDom column - cache rectangles to bitmapimage

    I am developing a superdom column that draws thousands of rectangles, but this approach is too slow. Instead of drawing each rectangle to the columns drawingcontext individually in OnRender, how can I create a bitmap outside of on render, paint the necessary rectangles, save the bitmap, and draw the bitmap once in OnRender? I know this is possible using the DirectX controls that charts/indicators use, but I'm confused how to implement this using WPF in a superdom column. Any help would be greatly appreciated!

    Thanks

    #2
    Hi, thanks for posting.

    We have an example of rendering a bitmap using SharpDX (attached). I do not know of an existing NinjaScript example of generating a bitmap at run time, but Microsoft has a page on the subject:

    https://docs.microsoft.com/en-us/dot...orkdesktop-4.8 (publicly available)

    Best regards,
    -ChrisL
    Attached Files
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hi Chris,

      This partially addresses my issue, but I need this functionality in a SuperDom column (that uses WPF), NOT an Indicator (that uses DirectX). This is the aspect that I am unable to solve on my own.

      Thanks again

      Comment


        #4
        Hi, thanks for your reply. Both types of scripts can override OnRender. We have a few default SuperDOM column examples that you can study through NinjaScript Editor>SuperDomColumns. The concept of the bitmap would be the same.

        Best regards,
        -ChrisL
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          The SuperDom column OnRender override is "OnRender(DrawingContext dc, double renderWidth)"

          The Indicator OnRender override is "OnRender(ChartControl chartControl, ChartScale chartScale)"

          My issue is using the superdom column DrawingContext dc "dc.DrawImage(ImageSource, Rect)"...converting a SharpDX.Direct2D1.Bitmap to an ImageSource that I can render in the SuperDom column. Does this make sense? Both namespaces use different rendering engines, and my understanding of both is not complete. I see that I am able to instantiate and modify SharpDX objects in the superdom column with WPF, but this is of no use if I can't convert them to ImageSource objects for dc.DrawImage()

          Thanks

          Comment


            #6
            Hi, Ill have a look and let you know what I found out.

            Thanks in advance.
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Hi, I looked into converting a System.Drawing.Bitmap to an ImageSource and found this page:

              https://stackoverflow.com/questions/...to-imagesource (publicly available)

              I do not have any examples written from within our library for generating this image, that would need to be researched further. As far as the OnRender method from the DOM column, this only needs to render the ImageSource using code similar to the example in the DrawingContext page.

              Kind regards,
              -ChrisL
              Chris L.NinjaTrader Customer Service

              Comment


                #8
                Do you guys have any sample code for actually loading and displaying an image in a SuperDOM column? This would be the most helpful

                Thanks

                Comment


                  #9
                  Hi, I made an example of drawing a bitmap image to the render rectangle. The image is loaded from the disk, so you will have to get an image you want to show and change the path name on line 55 to test the example.

                  Kind regards,
                  -ChrisL
                  Attached Files
                  Chris L.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by wzgy0920, 04-20-2024, 06:09 PM
                  2 responses
                  26 views
                  0 likes
                  Last Post wzgy0920  
                  Started by wzgy0920, 02-22-2024, 01:11 AM
                  5 responses
                  32 views
                  0 likes
                  Last Post wzgy0920  
                  Started by wzgy0920, Yesterday, 09:53 PM
                  2 responses
                  49 views
                  0 likes
                  Last Post wzgy0920  
                  Started by Kensonprib, 04-28-2021, 10:11 AM
                  5 responses
                  192 views
                  0 likes
                  Last Post Hasadafa  
                  Started by GussJ, 03-04-2020, 03:11 PM
                  11 responses
                  3,234 views
                  0 likes
                  Last Post xiinteractive  
                  Working...
                  X