Fixed issue with flipped ifcblobtexture loaded to blender

This commit is contained in:
Andrej730
2023-12-25 15:35:35 +05:00
parent 3221219f4a
commit 8ddd349f8b
2 changed files with 10 additions and 7 deletions
+4 -3
View File
@@ -273,11 +273,12 @@ class Loader(blenderbim.core.tool.Loader):
value = texture["RasterCode"]
image_bytes = int(value, 2).to_bytes(len(value) // 8, "big")
pil_image = Image.open(io.BytesIO(image_bytes))
pil_image.save("test_image.png")
byte_to_normalized = 1.0 / 255.0
bpy_image = bpy.data.images.new("blob_texture", width=pil_image.width, height=pil_image.height)
bpy_image.pixels[:] = (
np.asarray(pil_image.convert("RGBA"), dtype=np.float32) * byte_to_normalized
).ravel()
# PIL returns rows ordered from top to bottom, blender from bottom to top
pil_pixel_data = np.asarray(pil_image.convert("RGBA"), dtype=np.float32)
bpy_image.pixels[:] = (pil_pixel_data * byte_to_normalized)[::-1].ravel()
bpy_image.pack()
return bpy_image