Creating Rectangle around Bitmap
I have an bitmap of 10*15 size now i want to create an bitmap from this existing bitmap with size 20开发者_StackOverflow中文版*30 but the increased area should be transparent ,bitmap should not be translated/scaled.
Bitmap b = Bitmap.createBitmap(
yourBitmap,
xMarginYouWant,
yMarginYouWant,
yourBitmap.getWidth() + xMarginYouWant * 2,
yourBitmap.getHeight() + yMarginYouWant * 2
);
I did not get your question.... The heading is "drawing rectangle around bitmap" but there is no description for rectangle in detail. If you want a rectangle then this can be done as follows....
RectF rect = new RectF(x,y,x+width,y+height);
canvas.drawRect(rect, paint);
Drawing bitmap refer other answers...
Create a new Bitmap
that's 20x30, create a Canvas
to hold that bitmap, and then Canvas.drawBitmap()
your 10x15 one into it.
Create first bitmap with this method:
Bitmap b=b.createBitmap (Bitmap source, int x, int y, int width, int height);
Give your height and width and proper x and y values.
精彩评论