composit and image updating fix

This commit is contained in:
x-o-i-o-x 2025-10-07 13:15:13 +02:00
parent 904b1c61b6
commit 51d148df80

View File

@ -46,18 +46,21 @@ def apply_color():
print("PIL image sizes: ", paint_mask_image.size, target_image.size, new_image.size) print("PIL image sizes: ", paint_mask_image.size, target_image.size, new_image.size)
print("PIL image modes: ", paint_mask_image.mode, target_image.mode, new_image.mode) print("PIL image modes: ", paint_mask_image.mode, target_image.mode, new_image.mode)
paint_mask_image.show() # paint_mask_image.show()
target_image.show() # target_image.show()
new_image.show() # new_image.show()
# Blend buffers # Blend buffers
blended_image = Image.composite(target_image, new_image, paint_mask_image) blended_image = Image.composite(new_image, target_image, paint_mask_image)
# blended_image.show()
# Convert blended image back to numpy array and normalize # Convert blended image back to numpy array and normalize
blended_pixels = np.asarray(blended_image).astype(np.float32) # blended_pixels = np.asarray(blended_image).astype(np.float32)
blended_pixels = np.array(blended_image, dtype=np.uint8).astype(np.float32) / 255.0
# Save texture # Save texture
normal_buffer.pixels[:] = blended_pixels.flatten() # normal_buffer.pixels[:] = blended_pixels.flatten()
normal_buffer.pixels[:] = tuple(blended_pixels.reshape(-1))
normal_buffer.update() normal_buffer.update()
print("Color applied") print("Color applied")