Loading an Image in graph

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
hallo888
Posts: 43
Joined: Wed Mar 26, 2014 10:56 am

Loading an Image in graph

Post by hallo888 » Wed Mar 26, 2014 11:14 am

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!

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Loading an Image in graph

Post by ArctionPasi » Wed Mar 26, 2014 6:49 pm

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.
LightningChart Support Team, PT

hallo888
Posts: 43
Joined: Wed Mar 26, 2014 10:56 am

Re: Loading an Image in graph

Post by hallo888 » Thu Mar 27, 2014 3:37 am

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.
Attachments
The white background is supposed to be transparent in the original file.
The white background is supposed to be transparent in the original file.
boeing.png (17.09 KiB) Viewed 8092 times
How to remove the orange background and resize the image using annotation properties?
How to remove the orange background and resize the image using annotation properties?
screenshot.jpg (241.12 KiB) Viewed 8092 times

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Loading an Image in graph

Post by ArctionPasi » Thu Mar 27, 2014 5:59 am

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.
LightningChart Support Team, PT

Post Reply