Reputation: 1793
How to draw a Bitmap on Android's Canvas with specified width, height, positionX, positionY? There is no such method in Canvas.drawBitmap(..); and resizing Bitmaps requires Android API 19 and higher.
Upvotes: 0
Views: 307
Reputation: 12122
There is no such method in Canvas.drawBitmap(..);
Really?
Take a look at the documentation:
http://developer.android.com/reference/android/graphics/Canvas.html
There are a lot of methods, for example:
drawBitmap(int[] colors, int offset, int stride, int x, int y, int width, int height, boolean hasAlpha, Paint paint)
or
drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint)
Try something and let me know, if this doesn't help you
UPDATE:
You can do the following:
1) scale bitmap
createScaledBitmap(Bitmap src, int dstWidth, int dstHeight, boolean filter)
Available from API 1 (http://developer.android.com/reference/android/graphics/Bitmap.html#createScaledBitmap(android.graphics.Bitmap, int, int, boolean))
2) draw bitmap at position (x, y):
drawBitmap(Bitmap, left, top, paint)
Available from API 1 http://developer.android.com/reference/android/graphics/Canvas.html#drawBitmap(android.graphics.Bitmap, float, float, android.graphics.Paint)
Upvotes: 1