我只是做了一个类,让我可以使用 ColorAjust 类修改饱和度亮度、对比度和色调等图像。
但我不知道如何在进行这些修改后保存该图像。
这是代码:
final Stage imageProcessStage = new Stage();
imageProcessStage.initModality(Modality.APPLICATION_MODAL);
imageImageProcess = new Image(ImagePathImageProcess);
imageViewImageProcess = ImageViewBuilder.create().image(imageImageProcess).build();
ColorAdjust colorAdjust = ColorAdjustBuilder.create().build();
imageViewImageProcess.setEffect(colorAdjust);
//
Label saturationLabel = LabelBuilder.create().text("Saturation").build();
GridPane.setConstraints(saturationLabel, 0, 0);
Slider saturationSlider = SliderBuilder.create().value(50).build();
colorAdjust.saturationProperty().bind(saturationSlider.valueProperty().divide(50).subtract(1));
GridPane.setConstraints(saturationSlider, 1, 0);
GridPane.setHgrow(saturationSlider, Priority.ALWAYS);
Label saturationValueLabel = LabelBuilder.create().minWidth(75).maxWidth(75).build();
saturationValueLabel.textProperty().bind(colorAdjust.saturationProperty().multiply(100).asString("%.2f%%"));
GridPane.setConstraints(saturationValueLabel, 2, 0);
//
Label hueLabel = LabelBuilder.create().text("Hue").build();
GridPane.setConstraints(hueLabel, 0, 1);
Slider hueSlider = SliderBuilder.create().value(50).build();
colorAdjust.hueProperty().bind(hueSlider.valueProperty().divide(50).subtract(1));
GridPane.setConstraints(hueSlider, 1, 1);
GridPane.setHgrow(hueSlider, Priority.ALWAYS);
Label hueValueLabel = LabelBuilder.create().minWidth(75).maxWidth(75).build();
hueValueLabel.textProperty().bind(colorAdjust.hueProperty().multiply(100).asString("%.2f%%"));
GridPane.setConstraints(hueValueLabel, 2, 1);
//
Label brightnessLabel = LabelBuilder.create().text("Brightness").build();
GridPane.setConstraints(brightnessLabel, 0, 2);
Slider brightnessSlider = SliderBuilder.create().value(50).build();
colorAdjust.brightnessProperty().bind(brightnessSlider.valueProperty().divide(50).subtract(1));
GridPane.setConstraints(brightnessSlider, 1, 2);
GridPane.setHgrow(brightnessSlider, Priority.ALWAYS);
Label brightnessValueLabel = LabelBuilder.create().minWidth(75).maxWidth(75).build();
brightnessValueLabel.textProperty().bind(colorAdjust.brightnessProperty().multiply(100).asString("%.2f%%"));
GridPane.setConstraints(brightnessValueLabel, 2, 2);
//
Label contrastLabel = LabelBuilder.create().text("Contrast").build();
GridPane.setConstraints(contrastLabel, 0, 3);
Slider contrastSlider = SliderBuilder.create().value(50).build();
colorAdjust.contrastProperty().bind(contrastSlider.valueProperty().divide(50).subtract(1));
GridPane.setConstraints(contrastSlider, 1, 3);
GridPane.setHgrow(contrastSlider, Priority.ALWAYS);
Label contrastValueLabel = LabelBuilder.create().minWidth(75).maxWidth(75).build();
contrastValueLabel.textProperty().bind(colorAdjust.contrastProperty().multiply(100).asString("%.2f%%"));
GridPane.setConstraints(contrastValueLabel, 2, 3);
//Validate Button
Button btnValider = new Button("Valider");
btnValider.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent event) {
// SAVE IMAGE HERE
}
});