ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Advice needed, Geomap slippymap
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Patrick Quinn

United Kingdom
81 Posts

Posted - Sep 28 2016 :  07:42:56  Show Profile  Reply
Hi

I wish to have a Geomap display as in the example, but replacing the marker pin with an arrow pointing at the GPS position, with the arrow rotated by an angle set by EXIF_GPSImgDirection. This would show the direction the camera was pointing in when the photo was taken.

I assume that rotating the arrow image in the ImageEnView DrawBackBuffer event would be too slow?

Would the best way be to make an array of 360 rotated bitmaps, loaded into the form, and then load the appropriate bitmap in the DrawBackBuffer event, or can you recommend a better method?

Thanks

Patrick

xequte

38615 Posts

Posted - Sep 30 2016 :  02:19:19  Show Profile  Reply
Hi Patrick

Whether it would be too slow would depend on the complexity of your arrow graphic, the smoothing filter you use and the number of arrows on screen.

It is probably not too slow for a simple arrow, but you should do a test.

The other option is an array, but you could probably simplify it to 36 images, for example, as users are unlikely to notice <10 degree variances.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

Patrick Quinn

United Kingdom
81 Posts

Posted - Oct 01 2016 :  17:53:32  Show Profile  Reply
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
Go to Top of Page

xequte

38615 Posts

Posted - Oct 04 2016 :  02:57:12  Show Profile  Reply
Nice, one



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: