Page 1 of 1
Loading an Image in graph
Posted: Wed Mar 26, 2014 11:14 am
by hallo888
Hi,
May i know is there any functions for loading of image(e.g. .png) into a graph? Apart from loading image as the map background or as annotations, i could not find any sample that simply just loads image into a graph. I intend to move the image layer on top of ViewXY graph.
Any sample code will be much appreciated.
Thanks!
Re: Loading an Image in graph
Posted: Wed Mar 26, 2014 6:49 pm
by ArctionPasi
Hi,
Background bitmap can be loaded like this:
Code: Select all
chart.ViewXY.GraphBackground.Bitmap.Image = (Bitmap) Image.FromFile("c:\\temp\\bg.png");
chart.ViewXY.GraphBackground.Bitmap.Layout = BitmapFillLayout.Stretch;
chart.ViewXY.GraphBackground.Style = RectFillStyle.Bitmap;
This image can't however be set on top of other elements. It is a
background.
There's ways to show bitmap over other objects, for example displaying them in Annotation's bitmap fill.
Re: Loading an Image in graph
Posted: Thu Mar 27, 2014 3:37 am
by hallo888
Hi Pasi,
Thanks for the reply. I have added the image i wanted as an Annotation but i am facing some issues:
1) How do i remove the background colour behind the image? The image is originally a .png file and the white area is transparent when i view it. Is there any settings that i could set to make it transparent?
Update: i am able to remove the gradient background by "vector.Fill.GradientColor = Color.Empty;". Is this the correct way?
2) The original size of the image is 498 by 594 pixels. Current i am setting the SizeScreenCoords to the pixel size and if i set any smaller than the actual pixels of the image file, the image will be cropped. Anyway that i could resize the image by using the Annotations properties instead of changing the image size (using a graphic editor software)?
3) How do i remove the line for the annotation? I now "remove" it by setting the TargetAxisValues and LocationAxisValues to the same position.
Appended below is my codes, what else am i lacking to do the above?
Code: Select all
MapCoordinate mp = new MapCoordinate(27, 0, 0, LatitudePostfix.S, 133, 0, 0, LongitudePostfix.E);
AnnotationXY vector = new AnnotationXY();
vector.MouseInteraction = true;
vector.TextStyle.Visible = false;
vector.BorderVisible = false;
vector.Shadow.Visible = false;
vector.LocationCoordinateSystem = CoordinateSystem.AxisValues;
vector.Fill.Bitmap.Image = ChartTools.ImageFromResource("Resources.boeing.png", System.Reflection.Assembly.GetExecutingAssembly());
vector.Fill.GradientColor = Color.Empty;
vector.Fill.Style = RectFillStyle.Bitmap;
vector.RotateAngle = 0;
vector.Sizing = AnnotationXYSizing.ScreenCoordinates;
vector.SizeScreenCoords.Height = 594;
vector.SizeScreenCoords.Width = 498;
vector.TargetAxisValues.X = mp.Longitude;
vector.TargetAxisValues.Y = mp.Latitude;
vector.LocationAxisValues.X = mp.Longitude;
vector.LocationAxisValues.Y = mp.Latitude;
m_chart.ViewXY.Annotations.Add(vector);
Can i also check is any any in-built interpolation function for 2 points in LightningChart?
Thank You in advanced.
Re: Loading an Image in graph
Posted: Thu Mar 27, 2014 5:59 am
by ArctionPasi
Hello,
1) setting
vector.Fill.Color = Color.Empty;
vector.Fill.GradientColor = Color.Empty;
makes the background not visible. You could as well use Color.Transparent.
Also set Shadow.Visible = false.
2) Set vector.Fill.Bitmap.Layout = Stretch;
3) Set vector.Style = Rectangle.
For interpolating a point between two given points (if you are asking that) there's a couple ChartTools.SolvePointBetweenPoints methods.