Bitmap rotation jitter around pivot
- by Manderin87
I am working on a asteriods clone and I have the ship graphic loaded as a 96x96 bitmap. When the player rotates the ship I rotate the bitmap by degree (float).
rotation function:
if(m_Matrix == null) {
m_Matrix = new Matrix();
} else {
m_Matrix.reset();
}
m_Matrix.setRotate(degree, m_BaseImage.getWidth() / 2,
m_BaseImage.getHeight() / 2);
m_RotatedImage = Bitmap.createBitmap(m_BaseImage, 0, 0, m_BaseImage.getWidth(),
m_BaseImage.getHeight(),
m_Matrix, true);
draw function:
m_Paint.setAntiAlias(true);
m_Paint.setFilterBitmap(true);
m_Paint.setDither(true);
canvas.drawBitmap(m_RotatedImage, (int) posX - m_RotatedImage.getWidth() / 2,
(int) posY - m_RotatedImage.getHeight() / 2, m_Paint);
When the bitmap is drawn, the bitmap jitters slightly around the pivot.
Can anyone fix or tell me why the bitmap is jittering around the pivot? It needs to be smooth.