# How To Place A Bitmap Image(pin) In Center Of The Canvas Circle(blue Circle)?

## 30 December 2018 - 1 answer

``````   int x = 1460;
int y = 800;

BitmapFactory.Options myOptions = new BitmapFactory.Options();
myOptions.inDither = true;
myOptions.inScaled = false;
myOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;// important
myOptions.inPurgeable = true;

Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
R.mipmap.map, myOptions);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setColor(Color.BLUE);
Bitmap workingBitmap = Bitmap.createBitmap(bitmap);
Bitmap mutableBitmap = workingBitmap.copy(Bitmap.Config.ARGB_8888, true);
Canvas canvas = new Canvas(mutableBitmap);
canvas.drawCircle(x, y, 25, paint);
Bitmap currentPin = BitmapFactory.decodeResource(getResources(),
R.mipmap.pushpin_blue);
canvas.drawBitmap(currentPin, x, y, null);
``````

I placed both pin and circle in same xy coordinates, But it showing like below shown image

To explain the problem consider you have:
1: 128 * 128 pixel circle
2: 128 * 128 pixel mipmap
Then if both locate in `x=0` and `y=0` the output will be

:

In order to put the bottom of mipmap in center of the blue circle, you should locate the mipmap in `x=0; y=0;` and circle in `x=0; y=64;` the output will be :

the reason why your mipmap is not placed over the circle is that mipmap size is bigger than the circle. so if:
1: the circle is 32 * 32 pixels
2: the mipmap is 128 * 128 pixels
Then if both locate in `x=0` and `y=0` the output will be: