Fix definition and use of non-indexed sprite color channels.

Our SpriteFrameType names refer to the byte channel order rather than
the bit order, meaning that SpriteFrameType.BGRA corresponds to the
standard Color.ToArgb() etc byte order when the (little-endian) integer
is read as 4 individual bytes.

The previous code did not account for the fact that non-indexed Png
uses big-endian storage for its RGBA colours, and that SheetBuilder
had the color channels incorrectly swapped to match and cancel this out.

New SpriteFrameType enums are introduced to distinguish between BGRA
(little-endian) and RGBA (big-endian) formats, and also for 24bit data
without alpha. The channel swizzling / alpha creation is now handled
when copying into the texture atlas, removing the need for non-png
ISpriteLoader implementations to allocate an additional temporary array
and reorder the channels during load.
This commit is contained in:
Paul Chote
2020-12-19 12:05:56 +00:00
committed by abcdefg30
parent 6e7ad9df25
commit ce09b402d0
15 changed files with 205 additions and 142 deletions

View File

@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
var count = 0;
var sb = sequences.SpriteCache.SheetBuilders[SpriteFrameType.Indexed];
var sb = sequences.SpriteCache.SheetBuilders[SheetType.Indexed];
foreach (var s in sb.AllSheets)
{
var max = s == sb.Current ? (int)sb.CurrentChannel + 1 : 4;
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
s.AsPng((TextureChannel)ChannelMasks[i], palette).Save("{0}.png".F(count++));
}
sb = sequences.SpriteCache.SheetBuilders[SpriteFrameType.BGRA];
sb = sequences.SpriteCache.SheetBuilders[SheetType.BGRA];
foreach (var s in sb.AllSheets)
s.AsPng().Save("{0}.png".F(count++));