我想在裁切之前增加图像的饱和度。 Here是示例图像,Here是饱和后我想要的结果(这是我使用网络工具完成的),要在我的android应用程序中实现此效果,我尝试使用GpuImage库。这是我尝试的代码:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (RESULT_OK == resultCode)
switch (requestCode) {
case PHOTO_REQUEST_CODE:
if (mImageFilePath != null) {
Bitmap bitmap = BitmapFactory.decodeFile(mImageFilePath);
gpuImageView.setImage(bitmap);
gpuImageSaturationFilter.setSaturation(range(i, 0f, 2f));
applyFiltersToBitmap();
Uri imagePath1 = getImageUri(this, bitmap, "");
CropImage.activity(imagePath1)
.start(this);
}
break;
case REQUEST_PICK_PHOTO:
Uri uri = data.getData();
gpuImageView.setImage(uri);
gpuImageSaturationFilter.setSaturation(range(i, 0f, 2f));
applyFiltersToBitmap();
if (uri != null) {
CropImage.activity(uri).start(this);
}
break;
case CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE:
CropImage.ActivityResult result = CropImage.getActivityResult(data);
Uri myUri = result.getUri();
try {
finalBitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), myUri);
} catch (IOException e) {
e.printStackTrace();
}
if (finalBitmap != null) {
mImageFilePath = myUri.toString();
if (mImageFilePath != null) {
startOCR(finalBitmap);
}
}
break;
default:
Toast.makeText(this, "ERROR: Image was not obtained.", Toast.LENGTH_SHORT).show();
}
}
过滤器方法:
protected void applyFiltersToBitmap() {
GPUImageFilterGroup group = new GPUImageFilterGroup();
group.addFilter(gpuImageSaturationFilter);
gpuImageView.setFilter(group);
gpuImageView.requestRender();
}
但是我看不出太大的区别,如何增加饱和度以获得所需的输出? GpuImage是正确的工具还是我应该使用其他工具?
感谢您的帮助。