Closed kayler-renslow closed 7 years ago
Although this doesn't fix the problem, this seems to be a better implementation than the current one.
int x = /*x position of image*/;
int y = /*y position of image*/;
int w = /*width of image (can be smaller or larger than actual image width)*/;
int h = /*height of image (can be smaller or larger than actual image height)*/;
Image img = /*JavaFX Image object*/;
Color multColor = /*JavaFX Color used to tint the image*/;
PerspectiveTransform imgTrans = new PerspectiveTransform(x, y, x+w, y, x+w, y+h, x, y+h);
imgTrans.setInput(new ImageInput(img));
gc.setEffect(new Blend(
BlendMode.MULTIPLY,
imgTrans,
new ColorInput(x, y, w, h, multColor)
)
);
gc.setFill(Color.TRANSPARENT);
gc.fillRect(x, y, w, h);
gc.setEffect(null); //clear the effect so any succeeding renders don't use it
How it works:
Actual solution to this issue:
int x = /*x position of image*/;
int y = /*y position of image*/;
int w = /*width of image (can be smaller or larger than actual image width)*/;
int h = /*height of image (can be smaller or larger than actual image height)*/;
Image img = /*JavaFX Image object*/;
Color multColor = /*JavaFX Color used to tint the image*/;
PerspectiveTransform imgTrans = new PerspectiveTransform(x, y, x+w, y, x+w, y+h, x, y+h);
imgTrans.setInput(new ImageInput(img));
gc.setEffect(
new Blend(
BlendMode.MULTIPLY,
imgTrans,
new Blend(
BlendMode.SRC_ATOP,
imgTrans,
new ColorInput(x, y, w, h, multColor)
)
)
);
gc.setFill(Color.TRANSPARENT);
gc.fillRect(x, y, w, h);
gc.setEffect(null); //clear the effect so any succeeding renders don't use it
How it works:
top_blend
for reference).
Applied the fix to controls in commit https://github.com/kayler-renslow/arma-dialog-creator/commit/becbb1bd15ae230be126b6c8a89b96271589dd71
An image with some transparency and a non white text color for the control blends correctly on the image, but it applies the blend over the transparency as well.
Current effect (ignore jpeg compression): http://i.imgur.com/4Zd8wa0.jpg
Desired effect (ignore jpeg compression): http://i.imgur.com/XwEC6Oi.jpg