ifSet(options, CROP_GRAVITY, (v) -> cropSourceOptions.setGravity(v)); ifSet(options, CROP_PERCENTAGE, (v) -> cropSourceOptions.setPercentageCrop(Boolean.parseBoolean(v))); ifSet(options, CROP_WIDTH, (v) -> cropSourceOptions.setWidth(Integer.parseInt(v))); ifSet(options, CROP_HEIGHT, (v) -> cropSourceOptions.setHeight(Integer.parseInt(v))); ifSet(options, CROP_X_OFFSET, (v) -> cropSourceOptions.setXOffset(Integer.parseInt(v)));
ifSet(options, CROP_GRAVITY, (v) -> cropSourceOptions.setGravity(v)); ifSet(options, CROP_PERCENTAGE, (v) -> cropSourceOptions.setPercentageCrop(Boolean.parseBoolean(v))); ifSet(options, CROP_WIDTH, (v) -> cropSourceOptions.setWidth(Integer.parseInt(v))); ifSet(options, CROP_HEIGHT, (v) -> cropSourceOptions.setHeight(Integer.parseInt(v))); ifSet(options, CROP_X_OFFSET, (v) -> cropSourceOptions.setXOffset(Integer.parseInt(v)));
@Override public TransformationSourceOptions deserialize(SerializedTransformationOptionsAccessor serializedOptions) { int newWidth = serializedOptions.getIntegerParam(PARAM_CROP_WIDTH, -1); int newHeight = serializedOptions.getIntegerParam(PARAM_CROP_HEIGHT, -1); if (newHeight == -1 && newWidth == -1) { return null; } int xOffset = serializedOptions.getIntegerParam(PARAM_CROP_X_OFFSET, 0); int yOffset = serializedOptions.getIntegerParam(PARAM_CROP_Y_OFFSET, 0); boolean isPercentCrop = serializedOptions.getParamWithDefault(PARAM_IS_PERCENT_CROP, false); String gravity = serializedOptions.getCheckedParam(PARAM_CROP_GRAVITY, String.class); CropSourceOptions cropOptions = new CropSourceOptions(); cropOptions.setGravity(gravity); cropOptions.setHeight(newHeight); cropOptions.setPercentageCrop(isPercentCrop); cropOptions.setWidth(newWidth); cropOptions.setXOffset(xOffset); cropOptions.setYOffset(yOffset); return cropOptions; }
@Override public TransformationSourceOptions deserialize(SerializedTransformationOptionsAccessor serializedOptions) { int newWidth = serializedOptions.getIntegerParam(PARAM_CROP_WIDTH, -1); int newHeight = serializedOptions.getIntegerParam(PARAM_CROP_HEIGHT, -1); if (newHeight == -1 && newWidth == -1) { return null; } int xOffset = serializedOptions.getIntegerParam(PARAM_CROP_X_OFFSET, 0); int yOffset = serializedOptions.getIntegerParam(PARAM_CROP_Y_OFFSET, 0); boolean isPercentCrop = serializedOptions.getParamWithDefault(PARAM_IS_PERCENT_CROP, false); String gravity = serializedOptions.getCheckedParam(PARAM_CROP_GRAVITY, String.class); CropSourceOptions cropOptions = new CropSourceOptions(); cropOptions.setGravity(gravity); cropOptions.setHeight(newHeight); cropOptions.setPercentageCrop(isPercentCrop); cropOptions.setWidth(newWidth); cropOptions.setXOffset(xOffset); cropOptions.setYOffset(yOffset); return cropOptions; }