A
A
Anton Peat2014-11-03 18:18:13
Java
Anton Peat, 2014-11-03 18:18:13

How to stretch an image to the width of the screen from Canvas?

Converted to bitmap blank

Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.drawable.res);

Then I display it on the canvas here:
c.drawBitmap(largeIcon,0,0,p);
largeIcon - a large picture and in landscape mode the picture is quite decently displayed, but in portrait mode there is an empty field below.
I need to somehow stretch the image in height, width of the screen.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2014-11-18
@id_aspin

Use drawBitmap (Bitmap bitmap, Rect src, Rect dst, Paint paint)
src - null , dst - equal to canvas size.
Draw the specified bitmap, scaling/translating automatically to fill the destination rectangle. If the source rectangle is not null, it specifies the subset of the bitmap to draw.
developer.android.com/reference/android/graphics/C...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question