Page 1 of 1

Export to image. Resolution of image too low.

Posted: Thu Dec 08, 2005 7:19 am
by 9087252
Dear Sir/Madam,

When exporting the TChart to JPEG (Quality = 100), TIF, WMF, ... we noticed that the image resolution was not high enough.


Our code :

Steema.TeeChart.Export.JPEGFormat jPEG;
jPEG = tChart2.Export.Image.JPEG;
jPEG.Height = tChart1.Height;
jPEG.Width = tChart1.Width;
jPEG.Quality =100;
jPEG.Save(outputPath);

or

tChart1.Export.Image.Metafile.bEnhanced = true;
tChart1.Metafile.Save(outputPath,System.Drawing.Imaging.ImageFormat.Emf);

Is there a way to increase the resolution of the exported image ?

Thanks & Kind regards,
Erwin

Posted: Mon Dec 12, 2005 4:06 pm
by narcis
Hi Erwin,

You could try setting the Quality property, at TChart's editor 3D tab, to "Best Quality" or "Antialias".

You can also set it using:

Code: Select all

			tChart1.Graphics3D.SmoothingMode= System.Drawing.Drawing2D.SmoothingMode.HighQuality;

Posted: Tue Dec 13, 2005 8:05 am
by 9087252
Hi,

I have tested the settings you suggested but there was no improvement found on resolution of the exported image.

The problem is not the quality of the chart. It's the quality of the exported image who's resolution is too low.

I did following tests :
* I exported the image to JPEG and EMF file, opened it in Microsoft Office Picture Manager and printed (on paper) the image. => RESULT : Quality = POOR.

* I printed (on paper) the image from within my application using : Chart1.Printer.Preview(); => RESULT : Quality = GOOD.

Because of the fact that the imagefile will be picked up by an other process (documentgenerator) that uses the image and fits it into a document, we need to export the chart to an image first.

Is there a way to increase the resolution of the image file?

Kind regards,
Erwin

[/list]

Posted: Tue Dec 13, 2005 11:18 am
by narcis
Hi Erwin,

To get the same results as you, could you please let us know which TeeChart version are you using?

Thanks in advance.

Posted: Tue Dec 13, 2005 11:57 am
by 9637251
Hi,

My version of the TeeChart.dll = 2.0.1992.14012

Erwin

Posted: Tue Dec 13, 2005 1:05 pm
by narcis
Hi Erwin,

We have tested again here using latest Debug Build version available at our Customer Download Area and there is almost no noticeable difference between the WinForm, the JPEG and the EMF file. Can you please download this version and test if it works at your end?

BTW: The code I used to create the images was:

Code: Select all

		private void button2_Click(object sender, System.EventArgs e)
		{
			Steema.TeeChart.Export.JPEGFormat jpeg = tChart1.Export.Image.JPEG;
			jpeg.Quality = 100;
			jpeg.Save(@"C:\temp\chart.jpeg");
		}

		private void button3_Click(object sender, System.EventArgs e)
		{
			System.Drawing.Imaging.Metafile m = tChart1.Metafile;
			m.Save(@"C:\temp\chart.emf", System.Drawing.Imaging.ImageFormat.Emf);
		}

Posted: Wed Dec 14, 2005 1:17 pm
by 9637251
Hi Narcis,

I downloaded the latest debug build version (2.0.2105.30289) and tested the export to image function again. This had no possitive result.
I also installed the latest release version, but again it had no effect.

The quality is still poor. You can see this when you look at the labels. Compare the labels at the X and Y axe from a printout (on paper !) made with the Teechart.Printer.preview function and the printout (on paper !) of the JPEG file. You should see definitely the difference in quality between the 2 printouts.
I even tried the "Demoproject", that comes with the installation of TeeChart, and compared the printouts of our JPEG file with the one we made with the demoproject : They both have the same problem with the quality of the labels.

Is there a way to send you some of samples of our JPEG-files ? So you could see it yourself?

Kind regards,
Erwin

Posted: Thu Dec 15, 2005 11:52 am
by Chris
Hi Erwin,

TeeChart uses code virtually identical to the following:
http://tinyurl.com/cuz3e
or
http://groups.google.es/group/microsoft ... ges.csharp
/browse_frm/thread/e6f5f06cc3eb3c25/0ace6f1bef1e9269?lnk=st&q
=creating+jpeg+files+in+c%23+group%3Amicrosoft.public.dotnet.*
&rnum=2&hl=en#0ace6f1bef1e9269

to create its JPEG files with the Quality property being the equivalent of the getQuality() method. The bitmap we pass to our version of this method is the one that can be accessed from the Steema.TeeChart.TChart.Bitmap property and is created thus:

Code: Select all

Bitmap b = new Bitmap(width, height, pixelformat); //width and height of chart
 Draw(Graphics.FromImage(b)); //internal teechart draw method
 return b;
This methodology is completely standard to the .NET Framework, as you can see, and as yet we have been able to find an alternative way to create JPEG files. You may like to experiment yourself with JPEG file creation using the Bitmap available from the Steema.TeeChart.TChart.Bitmap property to see if you can find a better way to create a JPEG. If you do, please don't hesitate to let us know :)

Posted: Fri Dec 16, 2005 10:39 am
by 9637251
Hi,

Is the bitmap image (Steema.TeeChart.TChart.Bitmap) of the chart also used when printing the image directly to the printer or is this done another way? And when exporting the chart to a PDF, is the TChart.Bitmap used here ?

Best regards,
Erwin

Posted: Fri Dec 16, 2005 12:32 pm
by Chris
Hi,

Printing uses the Graphics of the System.Drawing.Printing.PrintPageEventArgs thus:

Code: Select all

e.Graphics.DrawImage(m /*metafile from Steema.TeeChart.TChart.Metafile*/,r /*rectangle to draw to*/ ,chart.chartBounds,GraphicsUnit.Pixel);
where Steema.TeeChart.TChart.Metafile is basically created thus:

Code: Select all

Bitmap bitmap = new Bitmap(1, 1, PixelFormat.Format24bppRgb);
Graphics gRef = Graphics.FromImage(bitmap);
IntPtr hDC = gRef.GetHdc();
Metafile mf = new System.Drawing.Imaging.Metafile(new MemoryStream(), hDC);
gRef.ReleaseHdc(hDC);
gRef.Dispose();
gRef = Graphics.FromImage(mf);
aChart.Draw(gRef, new Rectangle(0, 0, width, height)); //internal Draw method
Again, all very standard .NET procedure for drawing to a printer canvas and for Metafile creation.

PDF exportation is a different issue as the PDF has its own proprietory "canvas language" which PDF readers can render. TChart has its own Steema.TeeChart.Drawing.Graphics3DPDF class to interpret its .NET native canvas primitives to PDF's "canvas language".