我想在我的安卓应用程序中使用WarpFilter
jhlabs
。为此,我使用了jhlabs提供的jar,但是在其中,没有WarpFilter类的定义。我参考了WarpFilter和这个链接。我尝试通过在应用程序中复制该类来使用它。但问题是,它使用了一些 android sdk 不支持的类。我也参考了谷歌代码链接,但它也没有为此提供任何实现。请任何人都可以建议我一些解决方案?有没有其他提供扭曲图像功能的库/罐子?请帮我解决这个问题。
谢谢。
使用如下过滤器:
final Bitmap bmporg = BitmapFactory.decodeByteArray(byteArrayorg, 0, byteArrayorg.length);
Line line1 = new Line(0, 0, bmporg.getWidth(), 0);
Line line2 = new Line(0, bmporg.getHeight()/2, bmporg.getWidth(), bmporg.getHeight()/2);
Line line3 = new Line(0, bmporg.getHeight(), bmporg.getWidth(), bmporg.getHeight());
final Line[] lineArray = {line1, line2, line3 };
Line line4 = new Line(0, 0, bmporg.getWidth(), bmporg.getHeight());
Line line5 = new Line(0, 0, bmporg.getWidth(), bmporg.getHeight());
Line line6 = new Line(0, 0, bmporg.getWidth(), bmporg.getHeight());
final Line[] lineArray2 = {line4, line5, line6 };
FieldWarpFilter fieldWarpFilter = new FieldWarpFilter();
fieldWarpFilter.setAmount(amountFieldWarpFilter);
fieldWarpFilter.setPower(powerFieldWarpFilter);
fieldWarpFilter.setStrength(strengthFieldWarpFilter);
fieldWarpFilter.setInLines(lineArray);
fieldWarpFilter.setOutLines(lineArray2);
int[] src22 = AndroidUtils.bitmapToIntArray(bmporg);
int width22 = bmporg.getWidth();
int height22 = bmporg.getHeight();
int[] dest22 = fieldWarpFilter.filter(src22, width22, height22);
Bitmap destBitmap = Bitmap.createBitmap(dest22, width22, height22, Bitmap.Config.ARGB_8888);
imageView1.setImageBitmap(destBitmap);