By Daniel Csimszi - Tuesday, January 21, 2014
Hi,
I am just wondering if it is possible to center an image for graph background instead of setting it to stretch?
I know I can set the background the way like that:
NImageFillStyle imageFillStyle = new NImageFillStyle("image path");
m_Chart.Wall(ChartWallType.Back).FillStyle = imageFillStyle; m_Chart.Wall(ChartWallType.Left).FillStyle = imageFillStyle; m_Chart.Wall(ChartWallType.Floor).FillStyle = imageFillStyle;
But that always re-sizes the picture.
Thank you, Daniel
|
By Nevron Support - Wednesday, January 22, 2014
Hi Daniel,
Yes - you can use the following code:
NImageFillStyle imageFill = new NImageFillStyle("c:\\temp\\maplayout.png"); imageFill.TextureMappingStyle.MapLayout = MapLayout.Centered; chart.Wall(ChartWallType.Back).FillStyle = imageFill;
More information on texture mapping can be found here: http://helpdotnetvision.nevron.com/Presentation_Graphics_AppearanceStyles_FillStyles_Texture_Mapping_Style.html
|
By Daniel Csimszi - Wednesday, January 22, 2014
Thank you, It works as a charm. I just have one more question. Is it possible to resize the picture as well?
Thank you, Daniel
|
By Daniel Csimszi - Wednesday, January 22, 2014
sorry I got the answer: source: http://stackoverflow.com/questions/87753/resizing-an-image-without-losing-any-quality
//resize picture //keeping quality Bitmap bm = new Bitmap("something.png"); Bitmap newImage = new Bitmap(100, 100); using (Graphics gr = Graphics.FromImage(newImage)) { gr.SmoothingMode = SmoothingMode.HighQuality; gr.InterpolationMode = InterpolationMode.HighQualityBicubic; gr.PixelOffsetMode = PixelOffsetMode.HighQuality; gr.DrawImage(bm, new Rectangle(0, 0, 100, 100)); }
//set picture for backgournd NImageFillStyle imageFill = new NImageFillStyle(newImage);
imageFill.TextureMappingStyle.MapLayout = MapLayout.Centered; m_Chart.Wall(ChartWallType.Back).FillStyle = imageFill;
nChartControl1.Refresh();
|
|