We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Background color is wrong

Hello, I used following code to save chart as JPEG file. My chart''s background color should be white but the saved image''s backgroud color becomes dark. I attached the image(resized to <2048) and the code here. Any idea? public void SaveAs() { SaveFileDialog pSaveFileDialog = new SaveFileDialog(); pSaveFileDialog.InitialDirectory=clsApp.NPMAPath+@"\Files\Export"; pSaveFileDialog.DefaultExt="*.bmp"; pSaveFileDialog.Filter = "BMP(*.bmp)|*.bmp|JPG(*.JPG)|*.JPG|WMF(*.WMF)|*.WMF|GIF(*.GIF)|*.Gif|Tiff(*.tif)|*.TIF|PNG(*.Png)|*.Png|Icon(*.ico)|*.ico"; pSaveFileDialog.Title = "Save As "; pSaveFileDialog.FileName="Untitled"; if (pSaveFileDialog.ShowDialog()==DialogResult.OK) { Image bitmap = new Bitmap(chtReport.ClientSize.Width, chtReport.ClientSize.Height); chtReport.Draw(bitmap); string sExt=System.IO.Path.GetExtension(pSaveFileDialog.FileName).ToLower(); switch (sExt) { case ".jpg": bitmap.Save(pSaveFileDialog.FileName, ImageFormat.Jpeg); break; case ".bmp": bitmap.Save(pSaveFileDialog.FileName, ImageFormat.Bmp); break; case ".wmf": bitmap.Save(pSaveFileDialog.FileName, ImageFormat.Wmf); break; case ".gif": bitmap.Save(pSaveFileDialog.FileName, ImageFormat.Gif); break; case ".tif": bitmap.Save(pSaveFileDialog.FileName, ImageFormat.Tiff); break; case ".png": bitmap.Save(pSaveFileDialog.FileName, ImageFormat.Png); break; case ".ico": bitmap.Save(pSaveFileDialog.FileName, ImageFormat.Icon); break; } bitmap.Dispose(); string sMsg="The graph has been saved to the file " +pSaveFileDialog.FileName+clsConst.NEW_LINE+"Do you want to open it now?"; DialogResult pDialogResult=MessageBox.Show(sMsg,clsConst.APP_CAPTION,MessageBoxButtons.YesNo,MessageBoxIcon.Question); if (pDialogResult==DialogResult.Yes) { clsComm.OpenFile(pSaveFileDialog.FileName); } } } Untitled_1329.zip

3 Replies

AD Administrator Syncfusion Team August 3, 2005 03:30 PM

Hi Lan, What version of Essential Studio/Chart are you using? I tested with the latest version and the code you provided and the background of the chart is retained correctly when saved. Please try running the sample linked to below and let me know if you see the same problem: http://www.syncfusion.com/support/user/Uploads/F32545_ChartJpegSave_4699.zip Thanks, Davis


LA Lan August 4, 2005 07:36 AM

My version is 3.2.1.0 When I compile your sample, got following compile errors. It looks like your sample used different version. C:\temp\F32545_ChartJpegSave_4699\ChartJpegSave\Form1.cs(99): ''Syncfusion.Windows.Forms.Chart.ChartAxis'' does not contain a definition for ''AutoSize'' C:\temp\F32545_ChartJpegSave_4699\ChartJpegSave\Form1.cs(107): ''Syncfusion.Windows.Forms.Chart.ChartAxis'' does not contain a definition for ''AutoSize'' C:\temp\F32545_ChartJpegSave_4699\ChartJpegSave\Form1.cs(101): ''Syncfusion.Windows.Forms.Chart.ChartAxis'' does not contain a definition for ''MakeBreaks'' C:\temp\F32545_ChartJpegSave_4699\ChartJpegSave\Form1.cs(109): ''Syncfusion.Windows.Forms.Chart.ChartAxis'' does not contain a definition for ''MakeBreaks'' C:\temp\F32545_ChartJpegSave_4699\ChartJpegSave\Form1.cs(103): ''Syncfusion.Windows.Forms.Chart.ChartAxis'' does not contain a definition for ''Size'' C:\temp\F32545_ChartJpegSave_4699\ChartJpegSave\Form1.cs(110): ''Syncfusion.Windows.Forms.Chart.ChartAxis'' does not contain a definition for ''Size'' C:\temp\F32545_ChartJpegSave_4699\ChartJpegSave\Form1.cs(104): ''Syncfusion.Windows.Forms.Chart.ChartAxis'' does not contain a definition for ''TickLabelsDrawingMode'' C:\temp\F32545_ChartJpegSave_4699\ChartJpegSave\Form1.cs(111): ''Syncfusion.Windows.Forms.Chart.ChartAxis'' does not contain a definition for ''TickLabelsDrawingMode'' C:\temp\F32545_ChartJpegSave_4699\ChartJpegSave\Form1.cs(114): ''Syncfusion.Windows.Forms.Chart.ChartControl'' does not contain a definition for ''PrintColorMode'' C:\temp\F32545_ChartJpegSave_4699\ChartJpegSave\Form1.cs(116): ''Syncfusion.Windows.Forms.Chart.ChartControl'' does not contain a definition for ''ScrollPrecision'' C:\temp\F32545_ChartJpegSave_4699\ChartJpegSave\Form1.cs(133): ''Syncfusion.Windows.Forms.Chart.ChartControl'' does not contain a definition for ''ZoomCancel'' C:\temp\F32545_ChartJpegSave_4699\ChartJpegSave\Form1.cs(134): ''Syncfusion.Windows.Forms.Chart.ChartControl'' does not contain a definition for ''ZoomDown'' C:\temp\F32545_ChartJpegSave_4699\ChartJpegSave\Form1.cs(135): ''Syncfusion.Windows.Forms.Chart.ChartControl'' does not contain a definition for ''ZoomIn'' C:\temp\F32545_ChartJpegSave_4699\ChartJpegSave\Form1.cs(136): ''Syncfusion.Windows.Forms.Chart.ChartControl'' does not contain a definition for ''ZoomLeft'' C:\temp\F32545_ChartJpegSave_4699\ChartJpegSave\Form1.cs(137): ''Syncfusion.Windows.Forms.Chart.ChartControl'' does not contain a definition for ''ZoomOut'' C:\temp\F32545_ChartJpegSave_4699\ChartJpegSave\Form1.cs(138): ''Syncfusion.Windows.Forms.Chart.ChartControl'' does not contain a definition for ''ZoomRight'' C:\temp\F32545_ChartJpegSave_4699\ChartJpegSave\Form1.cs(139): ''Syncfusion.Windows.Forms.Chart.ChartControl'' does not contain a definition for ''ZoomUp'' C:\temp\F32545_ChartJpegSave_4699\ChartJpegSave\Form1.cs(88): ''Syncfusion.Windows.Forms.Chart.ChartLegend'' does not contain a definition for ''ItemsSize'' C:\temp\F32545_ChartJpegSave_4699\ChartJpegSave\Form1.cs(89): ''Syncfusion.Windows.Forms.Chart.ChartLegend'' does not contain a definition for ''ItemsTextAligment'' C:\temp\F32545_ChartJpegSave_4699\ChartJpegSave\Form1.cs(91): ''Syncfusion.Windows.Forms.Chart.ChartLegend'' does not contain a definition for ''OnlyColumnsForFloating'' C:\temp\F32545_ChartJpegSave_4699\ChartJpegSave\Form1.cs(93): ''Syncfusion.Windows.Forms.Chart.ChartLegend'' does not contain a definition for ''SetDefSizeForCustom'' C:\temp\F32545_ChartJpegSave_4699\ChartJpegSave\Form1.cs(89): The designer cannot process the code at line 89: this.chtReport.Legend.ItemsTextAligment = Syncfusion.Windows.Forms.Chart.VerticalAlignment.Center; The code within the method ''InitializeComponent'' is generated by the designer and should not be manually modified. Please remove any changes and try opening the designer again.


DJ Davis Jebaraj Syncfusion Team August 5, 2005 03:16 PM

Hi Lan, I have changed the sample to use version 3.2.1.0 and attached it again: F32545_ChartJpegSave1_4159.zip Thanks, Davis

Loader.
Live Chat Icon For mobile
Up arrow icon