Page 1 of 1

how to save image?

Posted: Sun Jan 12, 2014 11:19 pm
by 16667970
Hi,NarcĂ­s Calvet,
I want to save image as jpg,but I must click button1 twice. The first click just saves a blank images.I donot know the reason.Codes are:

Code: Select all

           private void button1_Click(object sender, EventArgs e)
        {
            TChart2.ClearChart();
            TChart2.BufferedDisplay = true;
            TChart2.Legend.Visible = false;
            TChart2.Panel.Color = (uint)ColorTranslator.ToWin32(Color.FromArgb(255, 255, 255));
            TChart2.Axis.Visible = false;
            TChart2.Axis.FastCalc = true;
            TChart2.Panel.MarginUnits = TeeChart.EMarginUnits.muPixels;
            TChart2.Panel.MarginLeft = 40;
            TChart2.Panel.MarginTop = 20;
            TChart2.Panel.MarginRight = 150;
            TChart2.Panel.MarginBottom = 0;
            TChart2.Aspect.View3D = false;
             TChart2.AddSeries(TeeChart.ESeriesClass.scFastLine);
             TChart2.Series(0).FillSampleValues(100);
             TChart2.Export.asJPEG.SaveToFile("d:\\abc.jpg");
        }
       private void chart()
        {
            TChart2.Canvas.Rectangle(TChart2.Width + 150, 50, 350, 150); 
        }

        private void TChart2_OnAfterDraw(object sender, EventArgs e)
        {
            chart();
        }
Good lucks,

Robinson

Re: how to save image?

Posted: Mon Jan 13, 2014 3:55 pm
by yeray
Hello Robinson,

Try calling the chart Environment.InternalRepaint method before the export:

Code: Select all

private void button1_Click(object sender, EventArgs e)
{
    //...
    TChart2.Series(0).FillSampleValues(100);
    TChart2.Environment.InternalRepaint();
    TChart2.Export.asJPEG.SaveToFile("d:\\abc.jpg");
}

Re: how to save image?

Posted: Mon Jan 13, 2014 11:29 pm
by 16667970
Hi,Yeray Alonso,
Thank for your quick reply.you solved my problem,but there occurs another problem:I cannot save images entirely. Teechart' painting is not finished,but images have been saved.If I save image when program finished,I can save entire image.In my program, If I select auto save checkbox and the mapping element, I can map all of them. Parts of codes are:

Code: Select all

            for (int j = 0; j < listViewEx1.CheckedItems.Count; j++)//cycle mapping element
            {
                 element = listViewEx1.CheckedItems[j].Text;
                .............
                   TChart2.Header.Caption = element;
                   MyDb.AllocateLegendColor
                 for (int i = 0; i < MyDb.zValue.Length; i++)
                {

                      UInt32 c = MyDb.allocate(MyDb.zValue[i]);
                     TChart2.Series(0).asColorGrid.AddXYZ(MyDb.xCoordinate[i], MyDb.zValue[i], MyDb.yCoordinate[i], "", c);
                 }
                    
                if (checkBoxX2.Checked == true)//judge if saved automatically
                 {
                   string ff = Application.StartupPath + "\\images\\" + sampleid + "_" + element + ".jpg";
                    try
                     {
                         TChart2.Environment.InternalRepaint();
                         TChart2.Export.asJPEG.SaveToFile(ff);
                     }
                     catch (Exception err4)
                     {
                         MessageBox.Show("'images' folder must exist in your system folder!\nImage cannot save.please set it up by hand", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                         break;
                     }
                 }
I attached my interface image, images saved automatically and manually.

thank you in advance

Good luck,
Robinson

Re: how to save image?

Posted: Wed Jan 15, 2014 12:26 pm
by yeray
Hello,

I'm not sure about what could be the exact problem. We'd need to get a simple example project we can run as-is to reproduce the problem here so we can easily debug it and wee what's happening.

However, in your code snipped I see two for-loops and the exportation is being made into the first one, just after the second one. Maybe you need to do the exportation out of the for loops so you are sure no more data is going to be added into the series.

Re: how to save image?

Posted: Sat Jan 18, 2014 9:31 am
by 16667970
Hi,Yeray Alonso,
I have emailed a simple example to [email protected],please help me to check it.
Thanks,
Robinson

Re: how to save image?

Posted: Sun Jan 19, 2014 9:08 am
by 16667970
Hi,Yeray Alonso,
Problem about how to save entire images continously I have solved.Before saving image, run
axTChart1.Environment.InternalRepaint();

only once,and next I use:
axTChart1.Repaint();
axTChart1.Export.asJPEG.SaveToFile(ff);
But I cannot show the correct x,y coordinates and values that different colors represent.
I look forward to your help,
Thanks,
Robinson

Re: how to save image?

Posted: Mon Jan 20, 2014 4:14 pm
by yeray
Hi,

It seems the Clicked function doesn't work fine with the ColorGrid series when IrregularGrid=true.
I've added it to the defect list:
http://bugs.teechart.net/show_bug.cgi?id=541

Re: how to save image?

Posted: Tue Jan 21, 2014 12:10 am
by 16667970
Hi,Yeray Alonso,
Thank for your reply.Do you think when the bug will be patched usually?I used teechart to develop a mapping program,but my customer wants to check if the concentrations represented by colors are right by comparing with test results of electron probe.Are there any other ways to work it out?
The data I send to you is squre,but if I set asColorGrid.IrregularGrid=false,I cannot draw any charts.
Thanks,
Robinson

Re: how to save image?

Posted: Tue Jan 21, 2014 12:49 pm
by yeray
Hi,

I'm afraid I can't tell you when this will be revised.
I'd suggest you to add yourself to the CC list to be automatically informed when the status of the ticket changes.