From 1023b4934473aef3c2ff24687bef4f41db1f702b Mon Sep 17 00:00:00 2001 From: drewcassidy Date: Mon, 5 Apr 2021 23:05:36 -0700 Subject: [PATCH] More test images --- .gitattributes | 1 + .gitignore | 1 + __init__.py | 25 +++++++++++-------- blocks/3color.dds | 3 +++ blocks/3color_black.dds | 3 +++ blocks/{3color black.png => 3color_black.png} | 0 blocks/3color_black_unpacked.png | 3 +++ blocks/3color_unpacked.png | 3 +++ blocks/greyscale.dds | 3 +++ blocks/greyscale_unpacked.png | 3 +++ 10 files changed, 34 insertions(+), 11 deletions(-) create mode 100644 .gitignore create mode 100644 blocks/3color.dds create mode 100644 blocks/3color_black.dds rename blocks/{3color black.png => 3color_black.png} (100%) create mode 100644 blocks/3color_black_unpacked.png create mode 100644 blocks/3color_unpacked.png create mode 100644 blocks/greyscale.dds create mode 100644 blocks/greyscale_unpacked.png diff --git a/.gitattributes b/.gitattributes index c6b4db6..7a1c5af 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,3 @@ *.png filter=lfs diff=lfs merge=lfs -text *.afdesign filter=lfs diff=lfs merge=lfs -text +*.dds filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bee8a64 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__ diff --git a/__init__.py b/__init__.py index e5367ec..b313ffe 100644 --- a/__init__.py +++ b/__init__.py @@ -1,17 +1,20 @@ from PIL import Image -import os +from collections import namedtuple +from quicktex.s3tc.bc1 import BC1Block +from quicktex import RawTexture +import os.path image_path = os.path.dirname(os.path.realpath(__file__)) -class Blocks: - # A block that should always encode greyscale, where every row of pixels is identical, and the left side is lighter than the right side - greyscale = Image.open(image_path + "/blocks/greyscale.png").tobytes("raw", "RGBX") +class BC1Blocks: + class Entry: + def __init__(self, filename, block): + path = os.path.join(image_path, 'blocks', filename) + self.image = Image.open(path).convert('RGBA') + self.texture = RawTexture.frombytes(self.image.tobytes('raw', 'RGBA'), *self.image.size) + self.block = block - # A block that should always encode 3-color when available. - # from left to right: red, yellow, yellow, green - three_color = Image.open(image_path + "/blocks/3color.png").tobytes("raw", "RGBX") - - # A block that should always encode 3-color with black when available - # from left to right: black, red, yellow, green - three_color_black = Image.open(image_path + "/blocks/3color black.png").tobytes("raw", "RGBX") + greyscale = Entry('greyscale_unpacked.png', BC1Block.frombytes(b'\xFF\xFF\x49\x4A\x78\x78\x78\x78')) + three_color = Entry('3color_unpacked.png', BC1Block.frombytes(b'\xE0\x07\x00\xF8\x29\x29\x29\x29')) + three_color_black = Entry('3color_black_unpacked.png', BC1Block.frombytes(b'\xE0\x07\x00\xF8\x27\x27\x27\x27')) diff --git a/blocks/3color.dds b/blocks/3color.dds new file mode 100644 index 0000000..c13189f --- /dev/null +++ b/blocks/3color.dds @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f70eb7aaa99f0a8144a0c9f8148860d05d8a5b35367f2bae0cd69624f96aaf16 +size 136 diff --git a/blocks/3color_black.dds b/blocks/3color_black.dds new file mode 100644 index 0000000..f4a3b45 --- /dev/null +++ b/blocks/3color_black.dds @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7da0970859031b1eab33b3c5af68cea71f00bbcbb72024aabb8366404010cdab +size 136 diff --git a/blocks/3color black.png b/blocks/3color_black.png similarity index 100% rename from blocks/3color black.png rename to blocks/3color_black.png diff --git a/blocks/3color_black_unpacked.png b/blocks/3color_black_unpacked.png new file mode 100644 index 0000000..cddb3b1 --- /dev/null +++ b/blocks/3color_black_unpacked.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b181064d82f0a01a39b013997cb8d4b89770538b040349c7e2d57d11f229a3b0 +size 103 diff --git a/blocks/3color_unpacked.png b/blocks/3color_unpacked.png new file mode 100644 index 0000000..4f4706a --- /dev/null +++ b/blocks/3color_unpacked.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e972786ea81ac7831c7e3123b8b8c88d576f26c67b9786d4db021f750755ad43 +size 100 diff --git a/blocks/greyscale.dds b/blocks/greyscale.dds new file mode 100644 index 0000000..636d4b2 --- /dev/null +++ b/blocks/greyscale.dds @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:25386ce4c8cde9e60bb4c691f9323d33247995a7e8992ebc7fa8fdfb1e616e3c +size 136 diff --git a/blocks/greyscale_unpacked.png b/blocks/greyscale_unpacked.png new file mode 100644 index 0000000..d20fda2 --- /dev/null +++ b/blocks/greyscale_unpacked.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:924c0628d829d7a99af0bfb18fdd88f135a690da45659b325c1f1f53663dca4b +size 103