Tom
Tom

Reputation: 4652

android get bitmap width and height after scaled by matrix

I use matrix to scale a bitmap and draw it on canvas, after it's scaled, is there a way to get the scale with of the bitmap? and it's scale height?

sx += 0.5f;
matrix.setScale(sx, sx);
matrix.postTranslate(left, top);
canvas.drawBitmap(bitmap, matrix, paint);

// here how to get the scaled width of bitmap?

This is part of my current project - a simple meme maker, so another question is that is there any good tutorials or resource (open source app) I can learn? I googled a lot, just get some pieces no complete tutorials.

Thanks.

Upvotes: 1

Views: 3085

Answers (1)

asenovm
asenovm

Reputation: 6517

I believe

Bitmap#getScaledHeight (Canvas canvas)

should do the job. If not try with

final int scaledHeight = bitmap.getHeight() * sx;

but the first one should work.

Upvotes: 3

Related Questions