I’m displaying a bitmap on Inside the ImageView and using the Canvas .
ImageView : it display the whole image not matter how large the image, it compress bitmap within the width/height of Imageview.
Canvas : canvas draw the bitmap but if the bitmap is larger it goes out of screen.
How to same behavior for bitmap on canvas like Imageview display.?
To resize a bitmap
take a look at
drawBitmapmethod in the canvas, Each overloaded method allows you to specify a size. For example here is the signature of one of the methodspublic void drawBitmap (int[] colors, int offset, int stride, int x, int y, int width, int height, boolean hasAlpha, Paint paint)It allows you specify the width and height .
Or
Use
public void drawBitmap (Bitmap bitmap, Matrix matrix, Paint paint)anduse
public void setScale (float sx, float sy)to resizeUse this to re-size the image based on your needs