How to shear image in Android?

佐手、 提交于 2019-12-12 20:09:07

问题


is it possible to shear image in Android? Seems I can't find any tutorial of it.


回答1:


Perhaps you've found the solution, but just in case, I think this is what you needed:

Bitmap src = BitmapFactory.decodeResource(this.getResources(), drawable.sample);
int width = src.getWidth();
int height = src.getHeight();
float skewX = 5.0;
float skewY = 6.0;
Matrix matrix = new Matrix();
matrix.setSkew(skewX, skewY);
Bitmap img = Bitmap.createBitmap(src, 0, 0, width, height, matrix, true);



回答2:


This May Help you

Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(), R.drawable.flower_blue);

        Bitmap croppedBmp = Bitmap.createBitmap(bitmapOrg, 0, 0,
                bitmapOrg.getWidth() / 2, bitmapOrg.getHeight());
        int h = bitmapOrg.getHeight();
        canvas.drawBitmap(bitmapOrg, 10, 10, paint);
        canvas.drawBitmap(croppedBmp, 10, 10 + h + 10, paint);


来源:https://stackoverflow.com/questions/11392821/how-to-shear-image-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!