Commit e6132ed7 by aptly-io

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 ...
parent df7a96a7
......@@ -94,7 +94,11 @@ import java.util.regex.Pattern;
if (colorExpression.length() == 7) {
// Set the alpha value
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();
}
return (int) color;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment