Hi Nigel
I've experimented and found that drawing a 'pie slice' using the Canvas.Pie method works well, the angle of the slice indicating the EXIF_GPSImgDirection.I draw cross hairs and a circle to show the GPS position.
The code is all in the DrawBackBuffer event and is a lot faster than using the bitmap of the pin, so should not cause any problems.
procedure TfrmMain.ImageEnViewMapDrawBackBuffer(Sender: TObject);
var
i, idx, x, y, x1, x2, x3, x4, y1, y2, y3, y4: Integer;
dLat, dLong: Double;
dPieAngle, dStartAngle, dStopAngle: Double;
const
r = 30; // radius of circle
rPie = 29; // radius of pie
ds = 2; // bevel offset
PieSlice: Double = 30; // Angle of pie slice
begin
with ImageEnViewMain.IO.Params do
begin
dLat := EXIF_GPSLatitude;
dLong := EXIF_GPSLongitude;
dPieAngle := EXIF_GPSImgDirection;
end;
x := map.LongitudeToBmpX(dLong);
y := map.LatitudeToBmpY(dLat);
with ImageEnViewMap.BackBuffer.Canvas do
begin
// Circle and cross hairs
Pen.Width := 1;
Brush.Style := bsClear;
// Drew in white offset by ds pixels
Pen.Color := clWhite;
Ellipse(ds + x - r, ds + y - r, ds + x + r, ds + y + r);
MoveTo(ds + x, ds + y - r - r);
LineTo(ds + x, ds + y + r + r);
MoveTo(ds + x - r - r, ds + y);
LineTo(ds + x + r + r, ds + y );
// Bevel effect, draw again in gray, no offset
Pen.Color := clDkGray;
Ellipse(x - r, y - r, x + r, y + r);
MoveTo(x, y - r - r);
LineTo(x, y + r + r);
MoveTo(x - r - r, y);
LineTo(x + r + r, y );
// Draw the pie slice;
with Brush do
begin
Style := bsClear;
Color := clyellow;
end;
Pen.Color := clred;
end;
dPieAngle := 90 - dPieAngle;
dStartAngle := dPieAngle - (PieSlice / 2);
dStopAngle := dPieAngle + (PieSlice / 2);
x1 := x - rPie;
y1 := y - rPie;
x2 := x + rPie;
y2 := y + rPie;
x3 := x + Round(rPie * Cos(DegToRad(dStartAngle)));
y3 := y - Round(rPie * Sin(DegToRad(dStartAngle)));
x4 := x + Round(rPie * Cos(DegToRad(dStopAngle)));
y4 := y - Round(rPie * Sin(DegToRad(dStopAngle)));
ImageEnViewMap.BackBuffer.Canvas.Pie(x1, y1, x2, y2, x3, y3, x4, y4);
end;
The code isn't optimised and could be cleaned up a bit but works ok.
Note that not all cameras record the image direction. My Panasonic Lumix TZ20 with built-in GPS does not, but my Marrex MX-G20M MKII Geotagger (which attaches to my Nikon D3200) does.
Patrick