Fix T45931: Blender Fails to generate previews.
Root of the issue was, preview generator was filling ID preview with unsigned int, when RNA only knows of signed integers (and thus generates a python exception when converting uint outside of int range)... Using the brand new and much simple float pixels accessor to PreviewImage now. Why this was working perfectly OK (it seems...) under Linux, and why error (py exception) was so badly and misleadingly reported on Windows, remains pitch black mystery to me.
This commit is contained in:
parent
a2714c9e4f
commit
4b1f3a7819
Notes:
blender-bot
2023-02-14 09:03:55 +01:00
Referenced by issue #45931, Blender Fails to generate previews
|
@ -304,11 +304,8 @@ def do_previews(do_objects, do_groups, do_scenes, do_data_intern):
|
|||
image = bpy.data.images[render_context.image, None]
|
||||
item = getattr(bpy.data, item_container)[item_name, None]
|
||||
image.reload()
|
||||
# Note: we could use struct module here, but not quite sure it'd give any advantage really...
|
||||
pix = tuple((round(r * 255)) + (round(g * 255) << 8) + (round(b * 255) << 16) + (round(a * 255) << 24)
|
||||
for r, g, b, a in zip(*[iter(image.pixels)] * 4))
|
||||
item.preview.image_size = (RENDER_PREVIEW_SIZE, RENDER_PREVIEW_SIZE)
|
||||
item.preview.image_pixels = pix
|
||||
item.preview.image_pixels_float[:] = image.pixels
|
||||
|
||||
# And now, main code!
|
||||
do_save = True
|
||||
|
|
Loading…
Reference in New Issue