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

Issue with Bitmap rendering

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

    Issue with Bitmap rendering

    Hello NT Support,

    I have tried to utilize the following NT8 addon at the forum located here:

    Hello folks, I'd like to add a logo on the top-left section of NT charts (please, see image attached). I have a PNG image. Is there a tool in NT to place it


    Verbatim and did not change anything, only placed my logo file in the directory that is needed, however when I run the indicator it presents with the following error:


    2020-05-07 14:16:07:722|3|4|Indicator 'SampleDrawBitmap': Error on calling 'OnRenderTargetChanged' method: SharpDX.SharpDXException: HRESULT: [0x88982F50], Module: [SharpDX.WIC], ApiCode: [WINCODEC_ERR_COMPONENTNOTFOUND/Componentnotfound], Message: The component cannot be found.

    at SharpDX.Result.CheckError()
    at SharpDX.WIC.ImagingFactory.CreateDecoderFromStream _(IntPtr streamRef, Nullable`1 guidVendorRef, DecodeOptions metadataOptions, BitmapDecoder decoderOut)
    at SharpDX.WIC.BitmapDecoder..ctor(ImagingFactory factory, Stream streamRef, DecodeOptions metadataOptions)
    at NinjaTrader.NinjaScript.Indicators.SampleDrawBitma p.LoadBitmapFromContentFile(String filePath)
    at NinjaTrader.NinjaScript.Indicators.SampleDrawBitma p.OnRenderTargetChanged()
    at NinjaTrader.Gui.NinjaScript.IndicatorRenderBase.se t_RenderTarget(RenderTarget value)

    #2
    Hello WHICKED,

    Thank you for the post.

    Have you tried with other images and also made sure the path you are using is correct? I tried the file from that post and pointed to an image and it worked. You may want to try the image from the following post: https://ninjatrader.com/support/foru...chart?t=107504

    I look forward to being of further assistance.

    JesseNinjaTrader Customer Service

    Comment


      #3
      Just tried the SampleBitmap provided there as well.

      Still the same issue. The PNG is located in the directory and still get the same error
      Attached Files

      Comment


        #4
        Hello WHICKED,

        I don't see anything from the images which would cause the error. Are you currently connected and have data on the chart that you are using for testing?

        As noted this worked on my end using the existing sample and the png from that post. If you cannot get this working with the sample you may want to email our platform support [at] ninjatrader.com and provide your log files so we can see if anything else sticks out.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          On Playback connection.
          Just uninstalled and reinstalled NT8

          8.0.21.1 64-bit

          Code:
          public class SampleDrawBitmap : Indicator
              {
                  private SharpDX.Direct2D1.Bitmap myBitmap;
                  private SharpDX.IO.NativeFileStream fileStream;
                  private SharpDX.WIC.BitmapDecoder bitmapDecoder;
                  private SharpDX.WIC.FormatConverter converter;
                  private SharpDX.WIC.BitmapFrameDecode frame;
          
                  protected override void OnStateChange()
                  {
                      if (State == State.SetDefaults)
                      {
                          Name = "SampleDrawBitmap";
                          Calculate = Calculate.OnBarClose;
                          IsOverlay = true;
                          ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                          IsSuspendedWhileInactive = true;
          
                      }
                      else if (State == State.Terminated)
                      {
                          if (myBitmap != null)         myBitmap.Dispose();
                          if (fileStream != null)     fileStream.Dispose();
                          if (bitmapDecoder != null)     bitmapDecoder.Dispose();
                          if (converter != null)         converter.Dispose();
                          if (frame != null)             frame.Dispose();
                      }
                  }
          
                  protected override void OnBarUpdate() { }
          
          
                  public override void OnRenderTargetChanged()
                  {
                      base.OnRenderTargetChanged();
                      if (RenderTarget == null || RenderTarget.IsDisposed) return;
          
                      // Dispose all Render dependant resources on RenderTarget change.
                      if (myBitmap != null)         myBitmap.Dispose();
                      if (fileStream != null)     fileStream.Dispose();
                      if (bitmapDecoder != null)     bitmapDecoder.Dispose();
                      if (converter != null)         converter.Dispose();
                      if (frame != null)             frame.Dispose();
          
                      // Neccessary for creating WIC objects.
                      fileStream = new SharpDX.IO.NativeFileStream(System.IO.Path.Combine(NinjaTrader.Core.Globals.UserDataDir, "woodenBox.png"), SharpDX.IO.NativeFileMode.Open, SharpDX.IO.NativeFileAccess.Read);
                      // Used to read the image source file.
                      bitmapDecoder = new SharpDX.WIC.BitmapDecoder(Core.Globals.WicImagingFactory, fileStream, SharpDX.WIC.DecodeOptions.CacheOnDemand);
                      // Get the first frame of the image.
                      frame = bitmapDecoder.GetFrame(0);
                      // Convert it to a compatible pixel format.            
                      converter = new SharpDX.WIC.FormatConverter(Core.Globals.WicImagingFactory);
                      converter.Initialize(frame, SharpDX.WIC.PixelFormat.Format32bppPRGBA);
                      // Create the new Bitmap1 directly from the FormatConverter.
                      myBitmap = SharpDX.Direct2D1.Bitmap.FromWicBitmap(RenderTarget, converter);
          
                  }
          
                  protected override void OnRender(NinjaTrader.Gui.Chart.ChartControl chartControl, NinjaTrader.Gui.Chart.ChartScale chartScale)
                  {
                      base.OnRender(chartControl, chartScale);
                      if (RenderTarget == null || Bars == null || Bars.Instrument == null || myBitmap == null)
                          return;
                      RenderTarget.DrawBitmap(myBitmap, new SharpDX.RectangleF((float)ChartPanel.W / 2, (float)ChartPanel.H / 2, 150, 150), 1.0f, SharpDX.Direct2D1.BitmapInterpolationMode.Linear);
                  }
          There is the code. As you can see nothing is changed between that file provided and what is on my environment.

          Attached Files

          Comment


            #6
            Hello WHICKED,

            Thank you for the reply.

            Could you please email our platform support [at] ninjatrader.com for further assistance? i would like to review your log file and also get a full attachment of the script use used if it is at all different from the other forum post. I was able to use the other forum posts sample with the linked woodenbox.png and can see that working in playback on my end.

            Please follow the steps below to manually attach your log and trace files to your emailso I may investigate this matter further.
            1. Open Windows File Explorer (hotkey = Windows key + E) Then navigate to, "Documents" (sometimes called, "My Documents") > 'NinjaTrader 8' folder
            2. Right click on the 'log' and 'trace' folders and select Send To> Compressed (zipped) Folder.
            3. Send the 2 compressed folders as attachments to this email.
            4. Once complete, you can delete these compressed folders.
            Please include a link to this post or ticket id: 2545278

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by adeelshahzad, Today, 03:54 AM
            5 responses
            32 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by stafe, 04-15-2024, 08:34 PM
            7 responses
            32 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by merzo, 06-25-2023, 02:19 AM
            10 responses
            823 views
            1 like
            Last Post NinjaTrader_ChristopherJ  
            Started by frankthearm, Today, 09:08 AM
            5 responses
            21 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by jeronymite, 04-12-2024, 04:26 PM
            3 responses
            43 views
            0 likes
            Last Post jeronymite  
            Working...
            X