Skip to content

Commit 9799eb5

Browse files
committed
Bug: Texture loader should support external image
1 parent 149d1ba commit 9799eb5

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

demosys/loaders/texture/array.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def load(self):
2424
data,
2525
)
2626

27-
if self.mipmap:
27+
if self.meta.mipmap:
2828
self.build_mipmaps()
2929

3030
self._close_image()

demosys/loaders/texture/pillow.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,22 @@ class PillowLoader(BaseLoader):
1111

1212
def __init__(self, meta):
1313
super().__init__(meta)
14-
self.image = getattr(meta, 'image', None)
15-
self.flip = getattr(meta, 'flip', True)
16-
self.mipmap = getattr(meta, 'mipmap', False)
14+
self.image = None
1715

1816
def load(self) -> Any:
1917
raise NotImplementedError()
2018

2119
def _open_image(self):
22-
self.meta.resolved_path = self.find_texture(self.meta.path)
23-
if not self.meta.resolved_path:
24-
raise ValueError("Cannot find texture: {}".format(self.meta.path))
20+
if self.meta.image:
21+
self.image = self.meta.image
22+
else:
23+
self.meta.resolved_path = self.find_texture(self.meta.path)
24+
if not self.meta.resolved_path:
25+
raise ValueError("Cannot find texture: {}".format(self.meta.path))
2526

26-
self.image = Image.open(self.meta.resolved_path)
27+
self.image = Image.open(self.meta.resolved_path)
2728

28-
if self.flip:
29+
if self.meta.flip:
2930
self.image = self.image.transpose(Image.FLIP_TOP_BOTTOM)
3031

3132
def _close_image(self):

demosys/loaders/texture/t2d.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ class Loader(PillowLoader):
66

77
def load(self):
88
"""Load a 2d texture"""
9-
if not self.image:
10-
self._open_image()
9+
self._open_image()
1110

1211
components, data = image_data(self.image)
1312

@@ -17,7 +16,7 @@ def load(self):
1716
data,
1817
)
1918

20-
if self.mipmap:
19+
if self.meta.mipmap:
2120
texture.build_mipmaps()
2221

2322
self._close_image()

0 commit comments

Comments
 (0)