Page 1 of 1

TeeChart for Compact Framework: JPEG export

Posted: Wed Nov 15, 2006 11:39 am
by 9640546
Hi,

it is possible to export the current TeeChart as a JPEG file (for TeeChart.Pocket)?
We want to display the current Chart in a WebPage!

The bitmap function have i found...

Posted: Wed Nov 15, 2006 11:50 am
by narcis
Hi VESCON,

Exporting is not currently available with TeeChart.Pocket.dll. It is already on our wish-list to be considered for inclusion in future releases.

Posted: Wed Nov 15, 2006 3:29 pm
by Chris
Hello,

TeeChart uses the Bitmap property/function internally to export a JPEG file. If you use the Chart property of the pocket TChart then you should be able to do something similar, e.g. (untested):

Code: Select all

	public  void Save(Stream stream) 
    {
      if (Width<=0) Width=400;
      if (Height<=0) Height=300;

      Bitmap b=chart.Bitmap(Width,Height);
      GetImageOptions(ref b);
      b.Save(stream,Encoder,EncoderParams);
      stream.Flush();
      b.Dispose();
    }
	
	public void GetImageOptions(ref Bitmap b) 
    {
      if (GrayScale) ConvertToGrayscale(ref b);
    }
	
	public ImageFormat GetFormat() 
    {
      return System.Drawing.Imaging.ImageFormat.Jpeg;
    }
	
	public ImageFormat Format 
    {
      get { return GetFormat(); }
    }
	
	public ImageCodecInfo Encoder 
    { 
      get { return GetEncoderInfo(Format.Guid); } 
    }
	
	public ImageCodecInfo GetEncoderInfo(Guid g) 
    {
      ImageCodecInfo[] encoders=ImageCodecInfo.GetImageEncoders();
      for (int t=0; t<encoders.Length; t++) 
      {
        if(encoders[t].FormatID==g)
          return encoders[t];
      }
      return null;
    }
	
	public EncoderParameters EncoderParams 
    {
      get 
      { 
        EncoderParameters result=new EncoderParameters(1);
        result.Param[0]=new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, Quality);
        return result; 
      }
    }  
	
	public int Quality
    {
      get { return quality; }
      set { quality=value; }
    }

Posted: Thu Nov 16, 2006 8:23 am
by 9640546
Hi,

many Thanks, i will try it ;)

Posted: Fri Dec 08, 2006 9:15 am
by 9640546
It doesen't work, because the classes 'ImageCodecInfo', 'EncoderParameters' etc. does not exist in CompactFramework :(

Posted: Wed Dec 20, 2006 12:58 pm
by narcis
Hi VESCON,

That's the reason why this can't be done :(.