Page 1 of 1

Working with image as principal item

Posted: Thu Aug 04, 2016 4:29 pm
by 9231205
I'm testing an eval copy of T-Chart .NET, trying to demonstrate proof of concept and suitability of use for our specialized applications. I'm using VS2015, Framework 4.6, C# Winforms. The installation and toolbox interfacing worked OK.

This application uses images as the principal items of interest. I want to do the following things while working with an image. Please tell me if the following tasks are feasible, and HOW to get me started doing this with explicit code samples.



I want to:

1. Load an image into a T-Chart component. Currently, the only way I see to do that is as a background image, which doesn't seem to provide the options I may require out of the box. This is the first place I'll need your help.

2. Scale the image in the T-Chart panel to fit by width, extending vertically as much as necessary to keep the original aspect ratio of the image intact. I may want to change the scaling by programmatically zooming, but always maintaining the original aspect ratio. I may also wish to scroll using visible scroll bars, along both axes as desired. I suspect that either some kind of data or axes definitions will be necessary to cause these things to work, just loading an image as a background image provides no obvious methods of this kind of manipulation.

3. Click on the image at any point, and have T-Chart draw a horizontal line with attributes of my choosing (color and width) at the vertical position of the click, over the image and annotate that line with text. That line needs to be created in such a way that it tracks with the T-Chart canvas position and needs to maintain that relative position as the image is zoomed or scrolled. I need to be able to compute the image pixel row position from that click point.

If you can confirm that these actions can be done, please provide any clues as to how to get started doing them so that I can complete my evaluation of the suitability of T-Chart for our specialized use.

Thanks.

-- Mike R.

Re: Working with image as principal item

Posted: Mon Aug 08, 2016 2:25 pm
by 10050769
Hello Mike,
1. Load an image into a T-Chart component. Currently, the only way I see to do that is as a background image, which doesn't seem to provide the options I may require out of the box. This is the first place I'll need your help.
To place an image in TChart component you need do something as code below:

Code: Select all

  private void button1_Click(object sender, EventArgs e)
      {
            //AddBackround image
                   
            tChart1.Panel.Image  = Image.FromFile(@"E:\tmp\NET\WindowsFormsApplication3\WindowsFormsApplication3\SteemaImages\Steema.jpg");
           tChart1.Panel.ImageMode = ImageMode.Center;

        }
That helps you to do you as you want.
2. Scale the image in the T-Chart panel to fit by width, extending vertically as much as necessary to keep the original aspect ratio of the image intact. I may want to change the scaling by programmatically zooming, but always maintaining the original aspect ratio. I may also wish to scroll using visible scroll bars, along both axes as desired. I suspect that either some kind of data or axes definitions will be necessary to cause these things to work, just loading an image as a background image provides no obvious methods of this kind of manipulation.
Maybe helps you use the ImageMode to change the ImageMode property to show imatge in your end.
3. Click on the image at any point, and have T-Chart draw a horizontal line with attributes of my choosing (color and width) at the vertical position of the click, over the image and annotate that line with text. That line needs to be created in such a way that it tracks with the T-Chart canvas position and needs to maintain that relative position as the image is zoomed or scrolled. I need to be able to compute the image pixel row position from that click point.
You can get the background image Height, Width or resolution propieties directly from the image and combining it with tChart1.ClickBackground and DrawLine tool you can make your request. Anyway, if you don’t use the DrawLine tool you can draw the line directly in the canvas.
In the demo project you find a simple example how is used drawLine Tool, specifically here:
All Featrues\Welcome !\Tools\Draw Lines
Also, if you are instested, you can upload the image in the ColorGrid Series. It maybe useful to get the column and color values.
You can find an example in the demo project, concretely in, All Features\Welcome !\Chart styles\Statistical\Color Grid\ColorGrid Bitmap


Hoping this helps.
Thanks in advance,

Re: Working with image as principal item

Posted: Fri Aug 19, 2016 7:46 pm
by 9231205
ImageMode does not scale the image. This image is MANY times larger than the size of the visible TeeChart panel, and I wish that image to be scaled so that the width of the image is equal to the width of the panel, with the height being proportioned to preserve the aspect ratio of the original image. I realize that this is not the purpose of the background image, and if you cannot do it, that's fine. You crash in 32 bit anyway as I change the ImageMode back and forth for the image which is a 57 MB TIF file.

Right tool for the right job I always say. Just hoping that we could use TeeChart for this instead of purchasing a different dedicated tool for this purpose.

Thanks for your assistance.

Re: Working with image as principal item

Posted: Mon Aug 22, 2016 8:34 am
by Christopher
Little Mike wrote:Right tool for the right job I always say. Just hoping that we could use TeeChart for this instead of purchasing a different dedicated tool for this purpose.
Please bear in mind that TeeChart gives unrestricted access to the entirety of the .NET Framework's image processing capabilities, which should enable you to modify your images as you require, e.g.

Code: Select all

    private void InitializeChart()
    {
      tChart1.Aspect.View3D = false;

      tChart1.BeforeDraw += TChart1_BeforeDraw;
    }

    private void TChart1_BeforeDraw(object sender, Graphics3D g)
    {
      Graphics gg = g.GDIplusCanvas;

      Rectangle rect = tChart1.Bounds;

      gg.DrawImage(Image.FromFile(@"D:\tmp\86-87.png"), rect);
    }