Reputation: 25204
Starting from grafika examples I am trying to capture a camera stream to file. Before encoding I need to apply some transformations:
I can do this:
Matrix.translateM(transform, 0, 0.5F, 0.5F, 0);
Matrix.rotateM(transform, 0, rotation, 0, 0, 1);
Matrix.translateM(transform, 0, -0.5F, -0.5F, 0);
The image comes in compressed along one axis. So I have to scale along that axis, than translate a bit so that we see the middle part. Again, I can do this as follows:
float scaleX = mScaleX; // < 1 or == 1
float scaleY = mScaleY; // < 1 or == 1
float scaleTranslX = (1F - scaleX) / 2F;
float scaleTranslY = (1F - scaleY) / 2F;
Matrix.translateM(transform, 0, scaleTranslX, scaleTranslY, 0);
Matrix.scaleM(transform, 0, scaleX, scaleY, 1);
The translation is to obtain a 'center crop' in the final result, as the encoder will only capture what's drawn in the given viewport.
However, I am lost at combining the two operations together. I have spent a few hours on this and what I have researched did not help. Can anyone figure this out?
Upvotes: 3
Views: 456