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
- Valentin Gies asked 4 years ago
- You must login to post comments
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
- Andrew Burnett-Thompson answered 4 years ago
- You must login to post comments
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
- Andrew Burnett-Thompson answered 4 years ago
- last edited 4 years ago
- You must login to post comments
Please login first to submit.