WIP: allow to load and use images on python scope #115543
Closed
Jaume Bellet
wants to merge 1 commits from
When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
(deleted):pr-0015-image-ui
into main
pull from: (deleted):pr-0015-image-ui
merge into: blender:main
blender:main
blender:npr-prototype
blender:blender-v4.3-release
blender:blender-v4.2-release
blender:pr-abs-path-fix-2
blender:blender-v3.6-release
blender:temp-sculpt-dyntopo
blender:icons-cleanup
blender:blender-v3.3-release
blender:brush-assets-project
blender:pr-extensions-tidy-space
blender:blender-v4.0-release
blender:universal-scene-description
blender:blender-v4.1-release
blender:blender-v3.6-temp_wmoss_animrig_public
blender:gpencil-next
blender:anim/animation-id-113594
blender:blender-projects-basics
blender:bridge-curves
blender:sculpt-blender
blender:asset-browser-frontend-split
blender:asset-shelf
blender:tmp-usd-python-mtl
blender:tmp-usd-3.6
blender:blender-v3.5-release
blender:blender-v2.93-release
blender:realtime-clock
blender:sculpt-dev
blender:bevelv2
blender:xr-dev
When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
1 Commits
Author | SHA1 | Message | Date | |
---|---|---|---|---|
fd014cbe37 |
Allows use to load an image and use in a blender from python scope, without the need to
load in bpy.data.images and hide it to users. Adds functions under bpy.utils.images to allow script manage the images. Adds a function to show the image on Layout. Example python code import os import bpy import bpy.utils.images img = None class ImageExamplePanel(bpy.types.Panel): """Creates a Panel in the Object properties window""" bl_label = "Image Example Panel" bl_idname = "OBJECT_PT_previews" bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "object" def draw(self, context): row = self.layout.row() row.template_image_ui(image_value = img['id'], scale= 1) def register(): global img # Set path to an existing file path = os.path.join(os.path.dirname(bpy.app.binary_path), 'image.png') img = bpy.utils.images.load('my_image', path) bpy.utils.register_class(ImageExamplePanel) def unregister(): global img bpy.utils.unregister_class(ImageExamplePanel) bpy.utils.images.release(img['id']) if __name__ == "__main__": register() |