-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
Hi,
I found your project while searching an issue with loading BLP files into Unity. You did an amazing job!
I have a blp file (version 1) from Warcaft 3 I'd like to load into Unity and since the content is JPEG, Unity assumes it has no alpha channel but I really suspect it has.
I tried loading it with the following python code:
from PIL import Image
with Image.open("Peasant.blp") as im:
im.getchannel('A')
im.show()And it failed saying there is no alpha channel. The call to show the image display a RGB (no alpha) image that is correct.
I have been searching in your code how you detect alpha channel and I found an error:
Pillow/src/PIL/BlpImagePlugin.py
Line 300 in aa0f412
| (self._blp_encoding,) = struct.unpack("<b", self._safe_read(1)) |
The BLP header for version 1 is incorrect.
You read 4 bytes there for 4 different values but in version 1, these 4 bytes are actually one unsigned integer 32bits (4 bytes) representing the number of bits for the alpha channel (which in my case is 8).
See this thread for more information about BLP specifications : https://www.hiveworkshop.com/threads/blp-specifications-wc3.279306/
Hope it helps.