-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from Trimatix/dev
Beta v0.8
- Loading branch information
Showing
35 changed files
with
692 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
etcpak | ||
pillow | ||
pillow | ||
tex2img | ||
etcpak |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
from .image import AEI, Texture | ||
from .constants import CompressionFormat, CompressionQuality | ||
from .codec import * | ||
from . import codecs | ||
from . import lib | ||
from .lib.imageOps import switchRGBA_BGRA | ||
from . import codec | ||
|
||
__version__ = "0.8" | ||
__all__ = ["AEI", "Texture", "CompressionFormat", "CompressionQuality", "codecs", "lib", "switchRGBA_BGRA", "codec"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from typing import Optional | ||
from typing import Optional | ||
from PIL import Image | ||
from ..codec import ImageCodecAdaptor, supportsFormats | ||
from ..constants import CompressionFormat, CompressionQuality | ||
from ..exceptions import DependancyMissingException | ||
|
||
try: | ||
import tex2img | ||
except ImportError as e: | ||
raise DependancyMissingException("Tex2ImgCodec", "tex2img", e) | ||
|
||
TEX2IMG_FORMAT_MAP = { | ||
# CompressionFormat.PVRTC14A: 12, # Tex2ImgCodec segfaults decoding PVRTC with all tests (#29) | ||
CompressionFormat.ATC: 14, | ||
CompressionFormat.DXT1: 5, | ||
CompressionFormat.DXT5: 6, | ||
CompressionFormat.ETC1: 0 | ||
} | ||
|
||
|
||
@supportsFormats(decompresses=TEX2IMG_FORMAT_MAP.keys()) | ||
class Tex2ImgCodec(ImageCodecAdaptor): | ||
@classmethod | ||
def decompress(cls, fp: bytes, format: CompressionFormat, width: int, height: int, quality: Optional[CompressionQuality]) -> Image.Image: | ||
if format not in TEX2IMG_FORMAT_MAP: | ||
raise ValueError(f"Codec {Tex2ImgCodec.__name__} does not support format {format.name}") | ||
|
||
decompressed = tex2img.basisu_decompress(fp, width, height, TEX2IMG_FORMAT_MAP[format]) # type: ignore[reportUnknownMemberType] | ||
im = Image.frombytes("RGBA", (width, height), decompressed, "raw") # type: ignore[reportUnknownMemberType] | ||
|
||
if im.mode != format.pillowMode: | ||
return im.convert(format.pillowMode) | ||
return im |
Oops, something went wrong.
a193d67
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverage Report