Profile Picture

Get image from chart control

Posted By Elvira Aminova 12 Years Ago
Author
Message
Elvira Aminova
questionmark Posted 12 Years Ago
View Quick Profile
Junior Member

Junior Member (10 reputation)Junior Member (10 reputation)Junior Member (10 reputation)Junior Member (10 reputation)Junior Member (10 reputation)Junior Member (10 reputation)Junior Member (10 reputation)Junior Member (10 reputation)Junior Member (10 reputation)

Group: Forum Members
Last Active: 10 Years Ago
Posts: 10, Visits: 1
I want to capture an image from NChartControl and then display it on the form.

I tried this:

//I add control to the form
System.Windows.Forms.Control control = new System.Windows.Forms.Control();
System.Drawing.Graphics g = control.CreateGraphics();

//control size is 100 to 100
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(100,100,g);
chart.ImageExporter.RenderToBitmap(bitmap, false);

I expected to see chart image on the control. Instead of that I see white rectangle.

What I did wrong?
Is it mistake to use System.Windows.Forms.Control to display an image on it?

Nevron Support
Posted 12 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

Hi Elvira,

The code below does not use the created bitmap in any way. The following code snippet shows how to render a bitmap and assign it to a picture box (this is the most simple approach you can use):

System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(pictureBox1.Width, pictureBox1.Height, PixelFormat.Format32bppArgb);
nChartControl1.ImageExporter.RenderToBitmap(bitmap,
false);
pictureBox1.Image = bitmap;

Hope this helps - let us know if you meet any problems.



Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic