Setting Pattern for TColor

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Test Always
Newbie
Newbie
Posts: 16
Joined: Mon Dec 05, 2016 12:00 am

Setting Pattern for TColor

Post by Test Always » Sat Feb 04, 2017 12:17 am

1) In the IDE I can set the "hatch" (pattern) for a TColorBandTool. The DFM looks like this:

object ChartTool1: TColorBandTool
Brush.Image.Data = {
07544269746D61707E000000424D7E000000000000003E000000280000001000
0000100000000100010000000000400000000000000000000000020000000000
000000000000FFFFFF00FFFF0000FFFF0000FFFF000077770000FFFF0000FFFF
0000FFFF000077770000FFFF0000FFFF0000FFFF000077770000FFFF0000FFFF
0000FFFF000077770000}
...

I would like to use that same pattern when I add tools at runtime (named "FIll 20%").

Is that possible?

2) When setting the Hatch in the IDE, the "Transparent" check box is disabled (and checked) but there is ability to configure the level of transparency. How can I do that?

Thank you,

Ed Dressel

Test Always
Newbie
Newbie
Posts: 16
Joined: Mon Dec 05, 2016 12:00 am

Re: Setting Pattern for TColor

Post by Test Always » Sat Feb 04, 2017 12:45 am

I tried to create my own PNG file and load it in to the IDE but it did not tile it, rather it stretched the 20x20 for the whole band (which didn't look so great).

I look forward to hearing back from you.

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

Re: Setting Pattern for TColor

Post by Yeray » Mon Feb 06, 2017 11:38 am

Hello,
Test Always wrote:1) In the IDE I can set the "hatch" (pattern) for a TColorBandTool. The DFM looks like this:
[...]
I would like to use that same pattern when I add tools at runtime (named "FIll 20%").

Is that possible?
Yes, you can do it as follows:

Code: Select all

var tmpBitmap: TBitmap;
//...
  with Chart1.Tools.Add(TColorBandTool) as TColorBandTool do
  begin
    Axis:=Chart1.Axes.Bottom;
    StartValue:=10;
    EndValue:=14;

    tmpBitmap:=TBitmap.Create;
    try
      GetTeeBrush(4,tmpBitmap);  //0 is "Diagonal Cross", 1 is "Fill 80%", 2 is "Fill 60%",...
      Brush.Image.Graphic:=tmpBitmap;
    finally
      tmpBitmap.Free;
    end;
  end;
Test Always wrote:2) When setting the Hatch in the IDE, the "Transparent" check box is disabled (and checked) but there is ability to configure the level of transparency. How can I do that?
The "Transparent" checkbox basically sets the Brush BackColor to clNone. It's only enabled when you set a BackColor ("Back..." button in the editor).
There's no Transparency (percentage) property associated.
Test Always wrote:I tried to create my own PNG file and load it in to the IDE but it did not tile it, rather it stretched the 20x20 for the whole band (which didn't look so great).
This seems to work fine for me here:

Code: Select all

  with Chart1.Tools.Add(TColorBandTool) as TColorBandTool do
  begin
    Axis:=Chart1.Axes.Bottom;
    StartValue:=18;
    EndValue:=22;
    Brush.Image.LoadFromFile('C:\tmp\20x20pattern.png');

    if not (Brush.Image.Graphic is TBitmap) then
    begin
      tmpBitmap:=TBitmap.Create;
      TeeSetBitmapSize(tmpBitmap,Brush.Image.Width,Brush.Image.Height);

      tmpBitmap.Canvas.Draw(0,0,Brush.Image.Graphic);

      Brush.Image.Bitmap:=tmpBitmap;
    end;
  end;
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

IanY
Newbie
Newbie
Posts: 1
Joined: Tue Apr 11, 2017 12:00 am

Re: Setting Pattern for TColor

Post by IanY » Wed Apr 12, 2017 2:17 pm

Is this a difference in rendering between TTeeCanvas3D and TGDIPlusCanvas?
In GDI mode it stretches the image, in GDI+ mode it tiles. This appears to be a change in TeeChart since 2012, when GDI mode also tiled.

The difference can be seen by running the current demo program Tee9New_win64Delphi25.exe, navigating to All Features | Welcome ! | Tools | Color Band | Transparency [which sets Brush.Image.Data] and toggling the GDI+ checkbox.

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

Re: Setting Pattern for TColor

Post by Yeray » Thu Apr 13, 2017 10:18 am

Hello,
IanY wrote:Is this a difference in rendering between TTeeCanvas3D and TGDIPlusCanvas?
In GDI mode it stretches the image, in GDI+ mode it tiles. This appears to be a change in TeeChart since 2012, when GDI mode also tiled.

The difference can be seen by running the current demo program Tee9New_win64Delphi25.exe, navigating to All Features | Welcome ! | Tools | Color Band | Transparency [which sets Brush.Image.Data] and toggling the GDI+ checkbox.
Indeed the images are stretched in GDI and not in GDIPlus. And I see the change was introduced in v2013.08.
However, I'm not sure it's worth fixing it in GDI since we always recommend using GDIPlus and we don't have plans to continue improving GDI.
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