Bitmap picture in background of Oxyplot Plots in vb.net
This discussion was imported from CodePlex
lparis77 wrote at 2014-03-02 11:07:
Hello,
First of all, thank you a lot for the continous development of that amazing Library !
One feature I would like to implement in my application is to put bitmap picture (from a file)
in background of my graphes.
I know it is possible (I had a look at the examples) through annotations but I have difficulties
to do it in VB.net since there is mismatch between Images classes and OxyImage classes.
I'm looking to have a command such as
"Annotation.imageSource.FromFile(Path ...)" but I have difficulties to handle "Stream classes" as input to OxyImage.
I will appreciate if anyone has some example how to put external files as input to OxyImage.
Regards.
First of all, thank you a lot for the continous development of that amazing Library !
One feature I would like to implement in my application is to put bitmap picture (from a file)
in background of my graphes.
I know it is possible (I had a look at the examples) through annotations but I have difficulties
to do it in VB.net since there is mismatch between Images classes and OxyImage classes.
I'm looking to have a command such as
"Annotation.imageSource.FromFile(Path ...)" but I have difficulties to handle "Stream classes" as input to OxyImage.
I will appreciate if anyone has some example how to put external files as input to OxyImage.
Regards.
maddog56 wrote at 2014-03-03 02:25:
This may help you get most of the way there. I'm not sure about the interpolate property seen below however. I'm still playing with this myself. Note that the bitmap picture I am referencing is included in my project as an embedded resource in lieu of
a file/path reference.
Dim m_AssInfo As System.Reflection.Assembly
m_AssInfo = System.Reflection.Assembly.GetExecutingAssembly
Dim ms As Stream = m_AssInfo.GetManifestResourceStream("Test4Tools.purple-top-white-bottom.png")
Dim image0 As OxyImage
image0 = New OxyImage(ms)
ms.Close()
Dim ianno As New ImageAnnotation
ianno.ImageSource = image0
ianno.Opacity = 0.2
ianno.X = New PlotLength(0.5, PlotLengthUnit.RelativeToPlotArea)
ianno.Y = New PlotLength(0.5, PlotLengthUnit.RelativeToPlotArea)
ianno.Width = New PlotLength(1, PlotLengthUnit.RelativeToPlotArea)
ianno.Height = New PlotLength(1, PlotLengthUnit.RelativeToPlotArea)
ianno.Layer = AnnotationLayer.BelowSeries
ianno.HorizontalAlignment = OxyPlot.HorizontalAlignment.Center
ianno.VerticalAlignment = VerticalAlignment.Middle
ianno.Interpolate = True
myModel.Annotations.Add(ianno)
Dim m_AssInfo As System.Reflection.Assembly
m_AssInfo = System.Reflection.Assembly.GetExecutingAssembly
Dim ms As Stream = m_AssInfo.GetManifestResourceStream("Test4Tools.purple-top-white-bottom.png")
Dim image0 As OxyImage
image0 = New OxyImage(ms)
ms.Close()
Dim ianno As New ImageAnnotation
ianno.ImageSource = image0
ianno.Opacity = 0.2
ianno.X = New PlotLength(0.5, PlotLengthUnit.RelativeToPlotArea)
ianno.Y = New PlotLength(0.5, PlotLengthUnit.RelativeToPlotArea)
ianno.Width = New PlotLength(1, PlotLengthUnit.RelativeToPlotArea)
ianno.Height = New PlotLength(1, PlotLengthUnit.RelativeToPlotArea)
ianno.Layer = AnnotationLayer.BelowSeries
ianno.HorizontalAlignment = OxyPlot.HorizontalAlignment.Center
ianno.VerticalAlignment = VerticalAlignment.Middle
ianno.Interpolate = True
myModel.Annotations.Add(ianno)
lparis77 wrote at 2014-03-03 19:51:
Thank you very much.
I began to test this approach from the example source on the codeplex website (Source code section) but
do not spend enough time to success. I will try again but it is not straigthforward if I want to change the picture during
execution.
Regards.
Customer support service by UserEcho