@@ -0,0 +1,2304 @@
+package org.osmdroid.views.overlay;%0A%0Aimport android.graphics.Bitmap;%0Aimport android.graphics.Canvas;%0Aimport android.graphics.Matrix;%0Aimport android.graphics.Paint;%0A%0Aimport org.osmdroid.util.GeoPoint;%0Aimport org.osmdroid.views.MapView;%0Aimport org.osmdroid.views.Projection;%0A%0A/**%0A * A ground overlay is an image that is fixed to 2 corners on a map.%0A * @author pasniak inspired by zkhan's code in Avare%0A *%0A */%0A@SuppressWarnings(%22WeakerAccess%22)%0Apublic class GroundOverlay2 extends Overlay %7B%0A%0A    private float   mLonL,%0A                    mLatU,%0A                    mLonR,%0A                    mLatD;%0A    protected Bitmap mImage;%0A%09protected float mBearing;%0A%09protected float mTransparency;%0A    private Matrix mStretchToFitTransformationMatrix;%0A%0A%09public GroundOverlay2() %7B%0A%09%09super();%0A%09%09mBearing = 0.0f;%0A%09%09mTransparency = 0.0f;%0A        mStretchToFitTransformationMatrix = new Matrix();%0A%09%7D%0A%0A%09public void setImage(Bitmap image)%7B%0A%09%09mImage = image;%0A%09%7D%0A%0A%09public Bitmap getImage()%7B%0A%09%09return mImage;%0A%09%7D%0A%0A%09public void setPosition(GeoPoint UL, GeoPoint RD)%0A    %7B%0A        mLatU = (float)UL.getLatitude();%0A        mLonL = (float)UL.getLongitude();%0A        mLatD = (float)RD.getLatitude();%0A        mLonR = (float)RD.getLongitude();%0A%09%7D%0A%0A%09public float getBearing()%7B%0A%09%09return mBearing;%0A%09%7D%0A%09%0A%09public void setBearing(float bearing)%7B%0A%09%09mBearing = bearing;%0A%09%7D%0A%09%0A%09public void setTransparency(float transparency)%7B%0A%09%09mTransparency = transparency;%0A%09%7D%0A%09%0A%09public float getTransparency()%7B%0A%09%09return mTransparency;%0A%09%7D%0A%09%0A%0A    @Override%0A    public void draw(Canvas canvas, MapView mapView, boolean shadow)%0A    %7B%0A%09%09if(null == mImage) %7B%0A%09%09%09return;%0A%09%09%7D%0A%0A        final Projection pj = mapView.getProjection();%0A%0A        long x0 = pj.getLongPixelXFromLongitude(mLonL),%0A             y0 = pj.getLongPixelYFromLatitude(mLatU),%0A             x1 = pj.getLongPixelXFromLongitude(mLonR),%0A             y1 = pj.getLongPixelYFromLatitude(mLatD);%0A%0A%09%09float scaleX = (float)(x1 - x0) / mImage.getWidth(),%0A%09%09      scaleY = (float)(y1 - y0) / mImage.getHeight();%0A        mStretchToFitTransformationMatrix.setScale(scaleX, scaleY);%0A        mStretchToFitTransformationMatrix.postTranslate(x0, y0);%0A%0A        Paint paint = new Paint();%0A        paint.setAlpha(255-(int)(mTransparency * 255));%0A%09%09canvas.drawBitmap(mImage, mStretchToFitTransformationMatrix, paint);%0A%09%7D%0A%7D%0A

add GroundOverlay2