66import android .graphics .Paint ;
77import android .graphics .Rect ;
88import android .graphics .drawable .Drawable ;
9+ import android .util .Log ;
910import android .view .MotionEvent ;
1011import android .view .VelocityTracker ;
1112import android .view .ViewConfiguration ;
@@ -209,9 +210,14 @@ public static void drawImage(Canvas canvas, Drawable drawable, int x, int y) {
209210 int width = drawable .getIntrinsicWidth ();
210211 int height = drawable .getIntrinsicHeight ();
211212
212- MPPointF drawOffset = MPPointF .Companion .getInstance ();
213- drawOffset .setX (x - (width / 2 ));
214- drawOffset .setY (y - (height / 2 ));
213+ MPPointF drawOffset1 = MPPointF .Companion .getInstance ();
214+ MPPointF drawOffset2 = MPPointF .Companion .getInstance ();
215+ drawOffset2 .setX (x - (width / 2 ));
216+ drawOffset2 .setY (y - (height / 2 ));
217+ drawOffset1 .setX (x - (width / 2f ));
218+ drawOffset1 .setY (y - (height / 2f ));
219+ Log .d ("drawOffsetOriginal" , drawOffset2 .toString ());
220+ Log .d ("drawOffsetCalc" , drawOffset1 .toString ());
215221
216222 drawable .copyBounds (mDrawableBoundsCache );
217223 drawable .setBounds (
@@ -222,7 +228,7 @@ public static void drawImage(Canvas canvas, Drawable drawable, int x, int y) {
222228
223229 int saveId = canvas .save ();
224230 // translate to the correct position and draw
225- canvas .translate (drawOffset .getX (), drawOffset .getY ());
231+ canvas .translate (drawOffset1 .getX (), drawOffset1 .getY ());
226232 drawable .draw (canvas );
227233 canvas .restoreToCount (saveId );
228234 }
0 commit comments