mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-11 08:27:29 -04:00
fix srgb alpha, tune values
This commit is contained in:
parent
7a74bf432a
commit
5877050837
@ -19,12 +19,12 @@ package example.jonathan2520;
|
|||||||
|
|
||||||
public class SRGBAverager {
|
public class SRGBAverager {
|
||||||
private static final SRGBTable SRGB = new SRGBTable();
|
private static final SRGBTable SRGB = new SRGBTable();
|
||||||
private static final float ALPHA_THRESHOLD = 0.6f;
|
private static final float ALPHA_THRESHOLD = 0.5f;
|
||||||
private static final int ALPHA_THRESHOLD_INT = (int) (0xFF * ALPHA_THRESHOLD);
|
private static final int ALPHA_THRESHOLD_INT = (int) (0xFF * ALPHA_THRESHOLD);
|
||||||
|
|
||||||
|
|
||||||
public static int average(int c0, int c1, int c2, int c3) {
|
public static int average(int c0, int c1, int c2, int c3) {
|
||||||
if ((((c0 | c1 | c2 | c3) ^ (c0 & c1 & c2 & c3)) & 0xff000000) == 0) {
|
if ((((c0 | c1 | c2 | c3) ^ (c0 & c1 & c2 & c3)) & 0x000000ff) == 0) {
|
||||||
// Alpha values are all equal. Simplifies computation somewhat. It's
|
// Alpha values are all equal. Simplifies computation somewhat. It's
|
||||||
// also a reasonable fallback when all alpha values are zero, in
|
// also a reasonable fallback when all alpha values are zero, in
|
||||||
// which case the resulting color would normally be undefined.
|
// which case the resulting color would normally be undefined.
|
||||||
@ -68,8 +68,8 @@ public class SRGBAverager {
|
|||||||
int ai = (int) (0.25F * a + 0.5F);
|
int ai = (int) (0.25F * a + 0.5F);
|
||||||
|
|
||||||
// check if opaque and transparent are mixed, if so check if target alpha is above specific threshold to keep it
|
// check if opaque and transparent are mixed, if so check if target alpha is above specific threshold to keep it
|
||||||
if ((a == 0) && (a0 == 0xff || a1 == 0xff || a2 == 0xff || a3 == 0xff)) {
|
if ((a == 0) || (a0 == 0xff || a1 == 0xff || a2 == 0xff || a3 == 0xff)) {
|
||||||
if (a1 < ALPHA_THRESHOLD_INT) {
|
if (ai < ALPHA_THRESHOLD_INT) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
ai = 0xff;
|
ai = 0xff;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user