ace/Source/ACE.DatLoader
Zynerji acbced8b75
Fix 16-bit texture decode: A4R4G4B4 and R5G6B5 (#4480)
Both formats expanded their packed channels with arithmetic that cannot
reach the top of the 8-bit range.

A4R4G4B4 used `nibble / 0xF * 255` in integer arithmetic. nibble / 15 is
0 for every nibble 0..14 and 1 only for 15, so all four channels - alpha
included - snapped to 0 or 255. In practice every affected texture
decoded to a single flat colour with binary alpha. Measured on a
CustomDM dat set, distinct colours and distinct alpha levels per texture
before -> after:

  06007068    1 ->  14 colours,   1 ->  1 alpha
  0600926C    1 ->  40 colours,   2 -> 15 alpha
  0600926E    1 ->  54 colours,   2 -> 16 alpha
  06009340    1 ->  70 colours,   2 ->  9 alpha
  06006430    1 ->   1 colours,   2 -> 11 alpha

255 / 15 == 17 exactly, so multiplying the nibble by 17 maps 0..15 onto
0..255 with no rounding error. The alpha nibble is now masked for
symmetry with the other three.

R5G6B5 expanded with a bare left shift, mapping a 5-bit value onto
0,8,16..248 and a 6-bit value onto 0,4,8..252. Neither reaches 255, so a
fully saturated white decoded to (248,252,248) - slightly dark and
slightly green tinted, since green keeps one more bit. Replicating the
high bits into the low ones spans the full range. Measured before ->
after on four textures whose brightest pixel is white:

  06006402, 06006404, 0600641D, 060096C0
  (248,252,248) -> (255,255,255)

and partial-range textures scale correspondingly, e.g. 06009694
(216,36,248) -> (222,36,255).

Affects every consumer of ACE.DatLoader that renders or exports
textures.
2026-08-13 01:04:08 -04:00
..
Entity match CBldPortal.PortalSide up to client (#4315) 2025-05-10 22:12:51 -04:00
FileTypes Fix 16-bit texture decode: A4R4G4B4 and R5G6B5 (#4480) 2026-08-13 01:04:08 -04:00
ACE.DatLoader.csproj Bump System.Drawing.Common from 10.0.9 to 10.0.10 (#4465) 2026-07-22 13:23:00 -04:00
BinaryReaderExtensions.cs Improving DatLoader for third-party apps (#1092) 2018-11-22 01:33:17 -05:00
CellDatDatabase.cs keepOpen option added to DatDatabase FileStream (#1097) 2018-11-20 07:45:09 -06:00
DatDatabase.cs Change static readonly fields to const fields. (#4211) 2024-08-24 14:32:35 +00:00
DatDatabaseHeader.cs ACE.DatLoader DatDirectory reading cleaned up (#624) 2018-02-06 10:18:38 -06:00
DatDatabaseType.cs Wire up support for HighRes DAT handling (#4469) 2026-07-29 13:03:36 -04:00
DatDatabaseTypeAttribute.cs ACE.DatLoader and ACE.DatLoader.Tests improvements (#614) 2018-02-03 17:54:07 -06:00
DatDirectory.cs ACE.DatLoader work (#625) 2018-02-07 09:02:24 -06:00
DatDirectoryHeader.cs Change static readonly fields to const fields. (#4211) 2024-08-24 14:32:35 +00:00
DatFile.cs Wire up support for HighRes DAT handling (#4469) 2026-07-29 13:03:36 -04:00
DatFileType.cs Update DatFileType extended info (#4015) 2023-06-10 16:07:27 -04:00
DatFileTypeAttribute.cs ACE.DatLoader and ACE.DatLoader.Tests improvements (#614) 2018-02-03 17:54:07 -06:00
DatFileTypeExtensionAttribute.cs ACE.DatLoader refactoring (#594) 2018-01-23 04:02:39 -06:00
DatFileTypeIdRangeAttribute.cs ACE.DatLoader and ACE.DatLoader.Tests improvements (#614) 2018-02-03 17:54:07 -06:00
DatManager.cs Dat file iteration checking (#2992) 2020-05-23 10:23:45 -07:00
DatReader.cs fix dat chunking (#4275) 2025-02-01 16:43:37 -05:00
DxtUtil.cs Image Export (#852) 2018-07-09 08:56:32 -07:00
IUnpackable.cs ACE.DatLoader and ACE.DatLoader.Tests improvements (#614) 2018-02-03 17:54:07 -06:00
LanguageDatDatabase.cs Adding house deeds, purchase requirements w/ config options (#1426) 2019-02-07 16:39:30 -05:00
PortalDatDatabase.cs Added Dat structures and tests for UILayout and DbProperties (#4208) 2024-08-13 14:45:30 -04:00
UnpackableExtensions.cs Adding items that can be leveled up (#1544) 2019-03-18 22:50:00 -04:00