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!
Loading an Image in graph
Moderator: Queue Moderators
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: Loading an Image in graph
Hi,
Background bitmap can be loaded like this:
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.
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;
There's ways to show bitmap over other objects, for example displaying them in Annotation's bitmap fill.
LightningChart Support Team, PT
Re: Loading an Image in graph
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?
Can i also check is any any in-built interpolation function for 2 points in LightningChart?
Thank You in advanced.
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);
Thank You in advanced.
- Attachments
-
- The white background is supposed to be transparent in the original file.
- boeing.png (17.09 KiB) Viewed 8131 times
-
- How to remove the orange background and resize the image using annotation properties?
- screenshot.jpg (241.12 KiB) Viewed 8131 times
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: Loading an Image in graph
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.
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.
LightningChart Support Team, PT