how to save image?

TeeChart for ActiveX, COM and ASP
Post Reply
zrandlbs
Newbie
Newbie
Posts: 37
Joined: Thu Dec 05, 2013 12:00 am

how to save image?

Post by zrandlbs » Sun Jan 12, 2014 11:19 pm

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

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: how to save image?

Post by Yeray » Mon Jan 13, 2014 3:55 pm

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");
}
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

zrandlbs
Newbie
Newbie
Posts: 37
Joined: Thu Dec 05, 2013 12:00 am

Re: how to save image?

Post by zrandlbs » Mon Jan 13, 2014 11:29 pm

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
Attachments
al.jpg
image saved manually,It was the last right result shown on my screen.
al.jpg (127.06 KiB) Viewed 18307 times
AM262-1_sample_Al27.jpg
not finished image,but it was saved by program
AM262-1_sample_Al27.jpg (130.87 KiB) Viewed 18307 times
a.jpg
interface
a.jpg (82.6 KiB) Viewed 18317 times

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: how to save image?

Post by Yeray » Wed Jan 15, 2014 12:26 pm

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.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

zrandlbs
Newbie
Newbie
Posts: 37
Joined: Thu Dec 05, 2013 12:00 am

Re: how to save image?

Post by zrandlbs » Sat Jan 18, 2014 9:31 am

Hi,Yeray Alonso,
I have emailed a simple example to [email protected],please help me to check it.
Thanks,
Robinson

zrandlbs
Newbie
Newbie
Posts: 37
Joined: Thu Dec 05, 2013 12:00 am

Re: how to save image?

Post by zrandlbs » Sun Jan 19, 2014 9:08 am

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

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: how to save image?

Post by Yeray » Mon Jan 20, 2014 4:14 pm

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
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

zrandlbs
Newbie
Newbie
Posts: 37
Joined: Thu Dec 05, 2013 12:00 am

Re: how to save image?

Post by zrandlbs » Tue Jan 21, 2014 12:10 am

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

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: how to save image?

Post by Yeray » Tue Jan 21, 2014 12:49 pm

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.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply