Fixed Flash viewer - dropshadow filter hideobject(compositeSource) parameter

This commit is contained in:
Jindra Petřík
2022-11-03 22:16:44 +01:00
parent 9f1970fdfa
commit b712fd4b44
3 changed files with 18 additions and 15 deletions

View File

@@ -93,7 +93,7 @@ public class DROPSHADOWFILTER extends FILTER {
@Override
public SerializableImage apply(SerializableImage src, double zoom) {
return Filtering.dropShadow(src, (int) Math.round(blurX * zoom), (int) Math.round(blurY * zoom), (int) (angle * 180 / Math.PI), distance * zoom, dropShadowColor.toColor(), innerShadow, passes, strength, knockout);
return Filtering.dropShadow(src, (int) Math.round(blurX * zoom), (int) Math.round(blurY * zoom), (int) (angle * 180 / Math.PI), distance * zoom, dropShadowColor.toColor(), innerShadow, passes, strength, knockout, compositeSource);
}
@Override

View File

@@ -286,8 +286,8 @@ public class Filtering {
BufferedImage shadowInner = null;
BufferedImage hilightInner = null;
if (type != OUTER) {
BufferedImage hilightIm = dropShadow(src, 0, 0, angle, distance, Color.red, true, iterations, strength, true);//new DropShadowFilter(blurX, blurY, strength, inner ? highlightColor : shadowColor, angle, distance, inner, true, iterations).filter(src
BufferedImage shadowIm = dropShadow(src, 0, 0, angle + 180, distance, Color.blue, true, iterations, strength, true); //new DropShadowFilter(blurX, blurY, strength, inner ? shadowColor : highlightColor, angle + 180, distance, inner, true, iterations).filter(src);
BufferedImage hilightIm = dropShadow(src, 0, 0, angle, distance, Color.red, true, iterations, strength, true, true);//new DropShadowFilter(blurX, blurY, strength, inner ? highlightColor : shadowColor, angle, distance, inner, true, iterations).filter(src
BufferedImage shadowIm = dropShadow(src, 0, 0, angle + 180, distance, Color.blue, true, iterations, strength, true, true); //new DropShadowFilter(blurX, blurY, strength, inner ? shadowColor : highlightColor, angle + 180, distance, inner, true, iterations).filter(src);
BufferedImage h2 = new BufferedImage(width, height, src.getType());
BufferedImage s2 = new BufferedImage(width, height, src.getType());
Graphics2D hc = h2.createGraphics();
@@ -306,8 +306,8 @@ public class Filtering {
BufferedImage shadowOuter = null;
BufferedImage hilightOuter = null;
if (type != INNER) {
BufferedImage hilightIm = dropShadow(src, 0, 0, angle + 180, distance, Color.red, false, iterations, strength, true);//new DropShadowFilter(blurX, blurY, strength, inner ? highlightColor : shadowColor, angle, distance, inner, true, iterations).filter(src
BufferedImage shadowIm = dropShadow(src, 0, 0, angle, distance, Color.blue, false, iterations, strength, true); //new DropShadowFilter(blurX, blurY, strength, inner ? shadowColor : highlightColor, angle + 180, distance, inner, true, iterations).filter(src);
BufferedImage hilightIm = dropShadow(src, 0, 0, angle + 180, distance, Color.red, false, iterations, strength, true, true);//new DropShadowFilter(blurX, blurY, strength, inner ? highlightColor : shadowColor, angle, distance, inner, true, iterations).filter(src
BufferedImage shadowIm = dropShadow(src, 0, 0, angle, distance, Color.blue, false, iterations, strength, true, true); //new DropShadowFilter(blurX, blurY, strength, inner ? shadowColor : highlightColor, angle + 180, distance, inner, true, iterations).filter(src);
BufferedImage h2 = new BufferedImage(width, height, src.getType());
BufferedImage s2 = new BufferedImage(width, height, src.getType());
Graphics2D hc = h2.createGraphics();
@@ -382,11 +382,11 @@ public class Filtering {
}
public static SerializableImage glow(SerializableImage src, int blurX, int blurY, float strength, Color color, boolean inner, boolean knockout, int iterations) {
return new SerializableImage(dropShadow(src.getBufferedImage(), blurX, blurY, 45, 0, color, inner, iterations, strength, knockout));
return new SerializableImage(dropShadow(src.getBufferedImage(), blurX, blurY, 45, 0, color, inner, iterations, strength, knockout, true));
}
public static SerializableImage dropShadow(SerializableImage src, int blurX, int blurY, float angle, double distance, Color color, boolean inner, int iterations, float strength, boolean knockout) {
return new SerializableImage(dropShadow(src.getBufferedImage(), blurX, blurY, angle, distance, color, inner, iterations, strength, knockout));
public static SerializableImage dropShadow(SerializableImage src, int blurX, int blurY, float angle, double distance, Color color, boolean inner, int iterations, float strength, boolean knockout, boolean compositeSource) {
return new SerializableImage(dropShadow(src.getBufferedImage(), blurX, blurY, angle, distance, color, inner, iterations, strength, knockout, compositeSource));
}
private static int cut(int val, int min, int max) {
@@ -399,7 +399,7 @@ public class Filtering {
return val;
}
private static BufferedImage dropShadow(BufferedImage src, int blurX, int blurY, float angle, double distance, Color color, boolean inner, int iterations, float strength, boolean knockout) {
private static BufferedImage dropShadow(BufferedImage src, int blurX, int blurY, float angle, double distance, Color color, boolean inner, int iterations, float strength, boolean knockout, boolean compositeSource) {
int width = src.getWidth();
int height = src.getHeight();
int[] srcPixels = getRGB(src);
@@ -424,18 +424,20 @@ public class Filtering {
blur(shadow, width, height, blurX, blurY, iterations, null);
}
for (int i = 0; i < shadow.length; i++) {
int mask = (srcPixels[i] >> 24) & 0xff;
if (!inner) {
mask = 255 - mask;
if (compositeSource) {
for (int i = 0; i < shadow.length; i++) {
int mask = (srcPixels[i] >> 24) & 0xff;
if (!inner) {
mask = 255 - mask;
}
shadow[i] = shadow[i] & 0xffffff + ((mask * ((shadow[i] >> 24) & 0xff) / 255) << 24);
}
shadow[i] = shadow[i] & 0xffffff + ((mask * ((shadow[i] >> 24) & 0xff) / 255) << 24);
}
BufferedImage retCanvas = new BufferedImage(width, height, src.getType());
setRGB(retCanvas, width, height, shadow);
if (!knockout) {
if (!knockout && compositeSource) {
Graphics2D g = retCanvas.createGraphics();
g.setComposite(AlphaComposite.DstOver);
g.drawImage(src, 0, 0, null);