Profile Picture

NImageExporter.CopyToClipboard fails silently writing to EMF - doesn't write anything to clipboard

Posted By Kevin Harrison 11 Years Ago

NImageExporter.CopyToClipboard fails silently writing to EMF - doesn't...

Author
Message
Kevin Harrison
Posted 11 Years Ago
View Quick Profile
Supreme Being

Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)

Group: Forum Members
Last Active: 3 Years Ago
Posts: 176, Visits: 1,865
I have a chart displaying a single series containing 1.1 million points, which I am attempting to copy to clipboard, using code like
  NImageExporter imageExporter = this.nevronControl.ImageExporter;  imageExporter.CopyToClipboard(imageExporter.DefaultImageSize, NResolution.ScreenResolution, NevronImageFormat);
When NevronImageFormat is EMF, nothing is written to the clipboard, whereas jpg works fine.
Is this a known issue? I can supply the 5.6Mb zipped chart xml if that would help.
Thanks
Kevin


Nevron Support
Posted 11 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: 1 days ago @ 1:54 AM
Posts: 3,054, Visits: 4,009
Hi Kevin,

Does the problem appear only with this particular configuration with 1.1 million points or with any chart that you try to export to EMF?

How do you understand that "nothing is written to the clipboard"? Do you try to paste the image in some program and which one?



Best Regards,
Nevron Support Team



Kevin Harrison
Posted 11 Years Ago
View Quick Profile
Supreme Being

Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)

Group: Forum Members
Last Active: 3 Years Ago
Posts: 176, Visits: 1,865

No, it's not any chart, most are fine. It seems a large number of points are required.

I know there nothing on the clipboard because it crashes Excel when trying to paste from the clipboard (how we originally found it), nothing is pasted into Word, and Clipboard.ContainsImage() returns false.

Interestingly if I use the export menu, the clipboard options fails, but the export to file option works. Could be a limtation of the clipboard?

Might it be worth making imageExporter.CopyToClipboard return a bool, which is the value of Clipboard.ContainsImage() ?

Thanks

Kevin



Nevron Support
Posted 11 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: 1 days ago @ 1:54 AM
Posts: 3,054, Visits: 4,009
Hi Kevin,

MSDN says about Clipboard.ContainsImage() that it "Indicates whether there is data on the Clipboard that is in the Bitmap format or can be converted to that format."

We guessed that when you store a metafile in the clipboard, you should check with ContainsData instead of ContainsImage:


bool containsMetafile = Clipboard.ContainsData(DataFormats.MetafilePict);


Our tests confirmed that ContainsData always returns true for EMF, while ContainsImage always returns false, regardless of the size of the metafile.

We also exported a line chart with 1100000 data points and again ContainsData returned true. However, pasting in Word 2010 was not successful as it hanged for a long time and was not able to render its document anymore. Pasting in Excel 2010 was almost successful - the image was rendered once and then the program hanged.

Here is the code that we used for the tests:


   void Form1_Load(object sender, EventArgs e)
   {      
      NChart chart = nChartControl1.Charts[0];
      NLineSeries series = new NLineSeries();
      series.DataLabelStyle.Visible = false;
      chart.Series.Add(series);

      Random rand = new Random();

      for (int i = 0; i < 1100000; i++)
      {
         series.Values.Add(rand.NextDouble());
      }
         

      NImageExporter imageExporter = nChartControl1.ImageExporter;

   //   NPngImageFormat format = new NPngImageFormat();
      NEmfImageFormat format = new NEmfImageFormat();
      imageExporter.CopyToClipboard(imageExporter.DefaultImageSize, NResolution.ScreenResolution, format);

      bool containsMetafile = Clipboard.ContainsData(DataFormats.MetafilePict);

      MessageBox.Show(containsMetafile ? "Yes" : "No");
   }




Best Regards,
Nevron Support Team



Kevin Harrison
Posted 11 Years Ago
View Quick Profile
Supreme Being

Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)

Group: Forum Members
Last Active: 3 Years Ago
Posts: 176, Visits: 1,865

Hi

Yep, my check for the format was wrong, but there is certainly nothing on the clipbaord for my chart (which has a 1.1M point series if that makes any difference from a line series). Clipboard.ContainsData(DataFormats.MetafilePict) returns false in my case.

Thanks

Kevin





Similar Topics


Reading This Topic