android-gpuimage - 使用GPUImageView进行图像矫直

时间:2015-10-31 09:08:11

标签: android android-gpuimageview

在我的Android应用程序中。我想使用android-gpuimage库制作图像矫直编辑功能,但GPUImageView没有提供ComboBox<ComboBox x:Name="cmbStatus" Width="75" DisplayMemberPath="status" ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=ListView}, Path=ItemsSource}" SelectedValuePath="status" SelectedValue="{Binding Path=status}"> </ComboBox> 的功能那么怎么可能请让我知道?这是要审核的代码:

getBitmap()

是否可以获得 mGPUImageView.setMatrix(matrix);

现在setMatrix() @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if(isStraightenEffectEnabled){ float angle = (progress - 45); float width = mGPUImageView.getWidth(); float height = mGPUImageView.getHeight(); if (width > height) { width = mGPUImageView.getHeight(); height = mGPUImageView.getWidth(); } float a = (float) Math.atan(height/width); // the length from the center to the corner of the green float len1 = (width / 2) / (float) Math.cos(a - Math.abs(Math.toRadians(angle))); // the length from the center to the corner of the black float len2 = (float) Math.sqrt(Math.pow(width/2,2) + Math.pow(height/2,2)); // compute the scaling factor float scale = len2 / len1; Matrix matrix = mGPUImageView.getMatrix(); if (mMatrix == null) { mMatrix = new Matrix(matrix); } matrix = new Matrix(mMatrix); float newX = (mGPUImageView.getWidth() / 2) * (1 - scale); float newY = (mGPUImageView.getHeight() / 2) * (1 - scale); matrix.postScale(scale, scale); matrix.postTranslate(newX, newY); matrix.postRotate(angle, mGPUImageView.getWidth() / 2, mGPUImageView.getHeight() / 2); 是一种getMatrix()的方法,GPUImageViewsetMatrix()不是getBitmap()类可用的方法。如果可能的话有任何解决方法吗?

3 个答案:

答案 0 :(得分:2)

在GPUImageView类中添加getGPUImage

public GPUImage getGPUImage() {
    return mGPUImage;
}

然后让你可以得到这样的位图:

mGPUImageView.getGPUImage().getBitmapWithFilterApplied();

答案 1 :(得分:2)

您还可以像这样获取位图: 位图位图= mGPUImageView.capture();

答案 2 :(得分:0)

您可以获得过滤后的位图渲染器和Pixelbuffer。这可能对你有所帮助。

GPUImageLookupFilter amatorka = new GPUImageLookupFilter();
amatorka.setBitmap(BitmapFactory.decodeResource(getResources(), getResources().getIdentifier("fil_" + position, "drawable", getPackageName())));
GPUImageRenderer renderer = new GPUImageRenderer(amatorka);
renderer.setImageBitmap(bitmap, false);
PixelBuffer buffer = new PixelBuffer(80, 80);
buffer.setRenderer(renderer);
buffer.getBitmap();