Skip to content

Commit

Permalink
Merge pull request #43 from Trimatix/dev
Browse files Browse the repository at this point in the history
v0.8.3
  • Loading branch information
Trimatix authored May 7, 2024
2 parents 764a524 + afdc931 commit 6e5b384
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/AEPi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
from . import codecs
from . import lib

__version__ = "0.8.2"
__version__ = "0.8.3"
__all__ = ["AEI", "Texture", "CompressionFormat", "CompressionQuality", "codecs", "lib", "codec"]
3 changes: 2 additions & 1 deletion src/AEPi/codecs/Tex2ImgCodec.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
CompressionFormat.ATC: 14,
CompressionFormat.DXT1: 5,
CompressionFormat.DXT5: 6,
CompressionFormat.ETC1: 0
CompressionFormat.ETC1: 0,
CompressionFormat.ETC2: 3
}


Expand Down
17 changes: 15 additions & 2 deletions src/AEPi/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
FORMAT_PILLOW_MODES: Dict["CompressionFormat", str] = {}
FORMAT_BITCOUNTS: Dict["CompressionFormat", int] = {}
BGRA_FORMATS: Set["CompressionFormat"] = set()
MIPMAPPABLE_FORMATS: Set["CompressionFormat"] = set()
MASK_MIPMAPPED_FLAG = 0b00000010
MASK_FORMAT_ID = 0b11111101

Expand All @@ -25,11 +26,12 @@ class CompressionFormat(Enum):
DXT3 = 0b00100001
DXT5 = 0b00100100
ETC1 = 0b01000000
ETC2 = 0b00010111


@classmethod
def fromBinary(cls, rawId: int) -> Tuple["CompressionFormat", bool]:
# Some non-mipmappable formats (uncompressed) have the mipmapping flag as 1, just as part of their ID
# Some non-mipmappable formats have the mipmapping flag as 1, just as part of their ID
if any(f.value == rawId for f in CompressionFormat):
return CompressionFormat(rawId), False

Expand Down Expand Up @@ -65,7 +67,7 @@ def bitcount(self):
@property
def supportsMipmapping(self):
# This will need some more testing to validate
return self.isCompressed
return self in MIPMAPPABLE_FORMATS


@property
Expand All @@ -84,6 +86,7 @@ def isBgra(self):
FORMAT_PILLOW_MODES[CompressionFormat.DXT3] = "RGBA"
FORMAT_PILLOW_MODES[CompressionFormat.DXT5] = "RGBA"
FORMAT_PILLOW_MODES[CompressionFormat.ETC1] = "RGB"
FORMAT_PILLOW_MODES[CompressionFormat.ETC2] = "RGBA"

FORMAT_BITCOUNTS[CompressionFormat.Uncompressed] = 8 # ?
FORMAT_BITCOUNTS[CompressionFormat.Uncompressed_UI] = 8 # ?
Expand All @@ -96,8 +99,18 @@ def isBgra(self):
FORMAT_BITCOUNTS[CompressionFormat.DXT3] = 8
FORMAT_BITCOUNTS[CompressionFormat.DXT5] = 8
FORMAT_BITCOUNTS[CompressionFormat.ETC1] = 4
FORMAT_BITCOUNTS[CompressionFormat.ETC2] = 8 # ?

BGRA_FORMATS.add(CompressionFormat.ETC1)
BGRA_FORMATS.add(CompressionFormat.ETC2)

MIPMAPPABLE_FORMATS.add(CompressionFormat.PVRTC12A)
MIPMAPPABLE_FORMATS.add(CompressionFormat.PVRTC14A)
MIPMAPPABLE_FORMATS.add(CompressionFormat.ATC)
MIPMAPPABLE_FORMATS.add(CompressionFormat.DXT1)
MIPMAPPABLE_FORMATS.add(CompressionFormat.DXT3)
MIPMAPPABLE_FORMATS.add(CompressionFormat.DXT5)
MIPMAPPABLE_FORMATS.add(CompressionFormat.ETC1)

FILE_TYPE_HEADER = b"AEimage\x00"
ENDIANNESS = Endianness("little", "<")
Expand Down

1 comment on commit 6e5b384

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/AEPi
   codec.py37392%22, 40, 119
   constants.py84792%38–44, 64, 70
   exceptions.py401172%18–19, 28–29, 39–40, 47, 54, 61, 68–69
src/AEPi/codecs
   EtcPakCodec.py291452%11–12, 22–30, 35–41
   RawCodec.py13285%15, 20
   Tex2ImgCodec.py19384%10–11, 28
   __init__.py8275%11–12
src/AEPi/image
   AEI.py2412789%121, 181, 185, 198, 225, 288, 294–297, 302, 326, 333, 341–342, 347–351, 382, 396–397, 436–437, 444–445, 488–489
   texture.py19289%29, 49
src/AEPi/lib
   binaryio.py24196%64
   imageOps.py9278%13–14
src/tests/image
   test_AEI.py199199%29
TOTAL8447591% 

Tests Skipped Failures Errors Time
43 0 💤 0 ❌ 0 🔥 0.315s ⏱️

Please sign in to comment.