How to control background color in TTeePolygon in TMapSeries when using a transparent svg or png image
-
- Newbie
- Posts: 2
- Joined: Mon Sep 18, 2023 12:00 am
How to control background color in TTeePolygon in TMapSeries when using a transparent svg or png image
I am able to load a transparent png or svg into the TTeePolygon.Brush.Image property but the background color is always white. Is it possible to set the background to some other color?
Re: How to control background color in TTeePolygon in TMapSeries when using a transparent svg or png image
Hello,
You could use
You could use
OnAfterDraw
event to manually draw transparent images with StretchDraw
method on top of the polygons. Ie:Code: Select all
uses Chart, TeeMapSeries, TeePng;
var Chart1: TChart;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1:=TChart.Create(Self);
with Chart1 do
begin
Parent:=Self;
Align:=alClient;
Color:=clWhite;
Gradient.Visible:=False;
Walls.Back.Color:=clWhite;
Walls.Back.Gradient.Visible:=False;
Legend.Hide;
View3D:=False;
TMapSeries(AddSeries(TMapSeries)).FillSampleValues;
OnAfterDraw:=Chart1AfterDraw;
end;
end;
procedure TForm1.Chart1AfterDraw(Sender: TObject);
var i: Integer;
map: TMapSeries;
image: TPicture;
begin
if not Assigned(Chart1) or (Chart1.SeriesCount<0) then
Exit;
image:=TPicture.Create;
image.LoadFromFile('D:\tmp\transp.png');
map:=TMapSeries(Chart1[0]);
for i:=0 to map.Count-1 do
begin
Chart1.Canvas.ClipPolygon(map.Polygon[i].GetPoints, Length(map.Polygon[i].GetPoints));
Chart1.Canvas.StretchDraw(map.Polygon[i].Bounds, image.Graphic);
Chart1.Canvas.UnClipRectangle;
end;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 2
- Joined: Mon Sep 18, 2023 12:00 am
Re: How to control background color in TTeePolygon in TMapSeries when using a transparent svg or png image
Thanks, in the meanwhile I found a solution where I prepare the bitmap with a background color before assigning it to the polygon