Fix RGBA color tuple parsing
The TTML 1 spec. defines an exact RGBA color tuple as #rrggbbaa See https://www.w3.org/TR/ttml1/#style-value-color Android's internal representation is ARGB. The correct parsing therefore requires a bit of extra byte shuffling ...
This commit is contained in:
parent
df7a96a7c4
commit
e6132ed742
@ -94,7 +94,11 @@ import java.util.regex.Pattern;
|
|||||||
if (colorExpression.length() == 7) {
|
if (colorExpression.length() == 7) {
|
||||||
// Set the alpha value
|
// Set the alpha value
|
||||||
color |= 0x00000000ff000000;
|
color |= 0x00000000ff000000;
|
||||||
} else if (colorExpression.length() != 9) {
|
} else if (colorExpression.length() == 9) {
|
||||||
|
int alpha = (int) color & 0x00000000000000ff; // get the transparency
|
||||||
|
color >>= 8; // put rgb bytes in their rightful place
|
||||||
|
color |= alpha << 24; // put the transparency byte in its rightful place
|
||||||
|
} else {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
return (int) color;
|
return (int) color;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user