[MGNLIMG-96] Support more color formats, including those with alpha channel, in ColverConverter#toColor(String) Created: 16/Apr/12  Updated: 09/Feb/17  Resolved: 12/May/16

Status: Closed
Project: Imaging
Component/s: image operations
Affects Version/s: None
Fix Version/s: 3.3

Type: Improvement Priority: Neutral
Reporter: Daniel Lipp Assignee: Robert Šiška
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Date of First Response:
Sprint: Kromeriz 43
Story Points: 2

 Description   

Support more color formats, including those with alpha channel, in ColverConverter#toColor(String).

Here's how this operation should work like:

@Test
public void testCanDecodeHexaWithAlphaChannel() {
    assertEquals(new Color(128, 64, 23, 35), ColorConverter.toColor("#80401723"));
}


 Comments   
Comment by Magnolia International [ 09/Mar/15 ]

Daniel,

When I introduced hexa support, the idea was to help web devs. Colors in Hexa don't support alpha, at least not on the web: http://www.w3.org/TR/css3-color/#numerical

That said, it could be useful to support the other syntaxes (rgb(), rgba(), hsl() and hsla(), and even the names (IIRC we currently only support those predefined as constants in java.awt.Color) – i'll update the title accordingly, but I don't know if/when we can realistically do this.

Comment by Magnolia International [ 16/Apr/15 ]

I got curious during a boring train ride, and I got this working. The parsing implementation is suboptimal but it works and is tested.
#rrggbbaa is still not supported, but this adds support for rgb(), rgba(), hsl() and hsla().
See branch feature/color-decode-MGNLIMG-96.

If we want to be closer to the CSS spec, we could also add support for more "names". (Currently we only support those names defined as constants in java.awt.Color.

Comment by Magnolia International [ 08/Oct/15 ]

Done on feature/color-decode-MGNLIMG-96 branch

Generated at Mon Feb 12 02:12:14 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.