fix image alpha scaling with summed color table

This commit is contained in:
Jesse Boyd 2018-05-23 16:19:38 +10:00
parent 6c05ec3b2a
commit 01554bf1fb
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
2 changed files with 3 additions and 1 deletions

View File

@ -686,6 +686,7 @@ public class CFICommands extends MethodCommands {
usage = "<url>",
desc = "Color terrain using glass"
)
// ![79,174,212,5:3,5:4,18,161,20]
@CommandPermissions("worldedit.anvil.cfi")
public void glass(FawePlayer fp, BufferedImage image, @Optional BufferedImage imageMask, @Optional Mask mask, @Switch('w') boolean disableWhiteOnly) throws ParameterException, WorldEditException {
CFISettings settings = assertSettings(fp);

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.object.collection;
import com.boydti.fawe.util.MathMan;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
@ -172,7 +173,7 @@ public class SummedColorTable {
float factor = this.areaInverses[area - 1];
float alpha = (totAlpha * factor);
factor = (factor * 256) / alpha;
return ((int) alpha << 24) + (((int) (totRed * factor)) << 16) + (((int) (totGreen * factor)) << 8) + (((int) (totBlue * factor)) << 0);
return (MathMan.clamp((int) alpha, 0, 255) << 24) + (((int) (totRed * factor)) << 16) + (((int) (totGreen * factor)) << 8) + (((int) (totBlue * factor)) << 0);
}
private long getVal(int row, int col, int index, long curr, long[] summed) {