Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2015-10-05 19:49:20 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-10-05 19:49:20 +0300
commit1cdf82d7f8dd117441405b99f744e2f7095e5c7c (patch)
tree520f3a938ae8aeafc37be7a0ce13527759a6a858 /release
parente5552f82415708778fefd11c0c57cd52213e823e (diff)
Image Py API: Expose 'load_exists' to RNA image load(), and extend load_image() helper.
Expose our `BKE_image_load_exists` feature through an optional parameter to `Image.load()`. Extend `image_utils.load_image()` with two optional parameters, to return existing image datablock if possible, and in that case, to force reloading said image. Needed by incomming 'import images as planes' addon enhancement.
Diffstat (limited to 'release')
-rw-r--r--release/scripts/modules/bpy_extras/image_utils.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/release/scripts/modules/bpy_extras/image_utils.py b/release/scripts/modules/bpy_extras/image_utils.py
index ff6d23badb6..ad774cd1bda 100644
--- a/release/scripts/modules/bpy_extras/image_utils.py
+++ b/release/scripts/modules/bpy_extras/image_utils.py
@@ -32,6 +32,8 @@ def load_image(imagepath,
convert_callback=None,
verbose=False,
relpath=None,
+ check_existing=False,
+ force_reload=False,
):
"""
Return an image from the file path with options to search multiple paths
@@ -60,6 +62,12 @@ def load_image(imagepath,
:type convert_callback: function
:arg relpath: If not None, make the file relative to this path.
:type relpath: None or string
+ :arg check_existing: If true, returns already loaded image datablock if possible
+ (based on file path).
+ :type check_existing: bool
+ :arg force_reload: If true, force reloading of image (only useful when `check_existing`
+ is also enabled).
+ :type force_reload: bool
:return: an image or None
:rtype: :class:`bpy.types.Image`
"""
@@ -86,7 +94,7 @@ def load_image(imagepath,
path = convert_callback(path)
try:
- image = bpy.data.images.load(path)
+ image = bpy.data.images.load(path, check_existing)
except RuntimeError:
image = None
@@ -102,6 +110,8 @@ def load_image(imagepath,
image = _image_load_placeholder(path)
if image:
+ if force_reload:
+ image.reload()
if relpath is not None:
# make relative
from bpy.path import relpath as relpath_fn