Pre loader

How to display an image using a DrawTexture and ITexture2D ?

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

Hi,
I have to display an image on a SciChartSurface using direct draw. I have seen on the forum that it can be done using ITexture2D and DrawTexture by i can’t achieve it.
Could you provide a small piece of code for that ?

Best regards,
Valentin

Version
V5
  • You must to post comments
1
0

You are in luck Valentin, I was doing some cleaning of our previous customer examples and we have an example of this API here:

CustomerExamples/UsingRenderContextAPI

In this example we create a Texture2D using IRenderContext2D and then draw it onto the RenderSurface

        // Create a Texture
        using (var rc = RenderSurface.GetRenderContext())
        {
            // Texture creation is very consuming, so recreate it as seldom as possible
            if (_texture == null)
            {
                _texture.SafeDispose();
                _texture = rc.CreateTexture(bitmap.PixelWidth, bitmap.PixelHeight);
            }
        }

        // ... 
        var desiredWidth = (int)RenderSurface.ActualWidth;
        var desiredHeight = (int)RenderSurface.ActualHeight;

        // Redraw occurs on dispose
        using (var rc = RenderSurface.GetRenderContext())
        {
            // Copy pixel data
            _texture.SetData(_pixels);

            // Render
            rc.DrawTexture(_texture, new Rect(new Size(desiredWidth, desiredHeight)));
        }

Best regards,
Andrew

  • You must to post comments
0
0

Hi Valentin,

Directly calling DrawTexture() is a non-standard use of the SciChart API (as I’ve explained on tech support to you! PS: you are educational licensed, should not be receiving support as this is part of our agreement). It is possible, but requires us to support you at a level that you are not eligible for. We do not have any examples for this and would have to create one.

Instead, I would recommend using the built-in method to draw an image in the chart, to use our Annotations API to place an image inside CustomAnnotation or BoxAnnotation.
https://www.scichart.com/questions/wpf/insert-image-to-box-annotation-as-backgraoud

If you would like to hire us to build samples for you, you can do, or upgrade to paid support!

Best regards,
Andrew

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies