Converting Hex colors to FColor using built-in capabilities erroneous.

If I’m understanding this correctly:

I left the * in on test #2, didn’t notice that FParse::HexDigit takes a single character not an array of them, and on top of that FParse::HexDigit returns an int, and not the uint that FColor uses to initialize so regardless it’ll always be off from what I expected.

As for the last 2 being out of expected order, it looks like my mental model & little endian is what did me in. I just don’t think in endianness anymore as I’ve been so insulated from it for such a long time.

/*FColor.h*/
#if PLATFORM_LITTLE_ENDIAN
	union { struct{ uint8 B,G,R,A; }; uint32 Bits; }; //<- I was seeing
#else
	union { struct{ uint8 A,R,G,B; }; uint32 Bits; };
#endif

/*The visual order of a  hexcolor  R='FE' G='D8' B='0D' A='FF'*/
union { struct{ uint8 R,G,B,A; }; uint32 Bits; }; // <-My mental model

Stupid oversights on my part explain why the conversion wasn’t as expected. Thank you for your time & assistance.

1 Like