move load_image into image_utils and add some docstrings to bpy_extras module.

This commit is contained in:
Campbell Barton
2011-05-28 09:34:45 +00:00
parent 245d36b706
commit a9dd90be78
5 changed files with 134 additions and 43 deletions

View File

@@ -22,7 +22,6 @@ __all__ = (
"ExportHelper",
"ImportHelper",
"axis_conversion",
"load_image",
"create_derived_objects",
"free_derived_objects",
"unpack_list",
@@ -162,24 +161,6 @@ def axis_conversion(from_forward='Y', from_up='Z', to_forward='Y', to_up='Z'):
assert("internal error")
# limited replacement for BPyImage.comprehensiveImageLoad
def load_image(imagepath, dirname):
import os
if os.path.exists(imagepath):
return bpy.data.images.load(imagepath)
variants = [imagepath, os.path.join(dirname, imagepath), os.path.join(dirname, os.path.basename(imagepath))]
for filepath in variants:
for nfilepath in (filepath, bpy.path.resolve_ncase(filepath)):
if os.path.exists(nfilepath):
return bpy.data.images.load(nfilepath)
# TODO comprehensiveImageLoad also searched in bpy.config.textureDir
return None
# return a tuple (free, object list), free is True if memory should be freed later with free_derived_objects()
def create_derived_objects(scene, ob):
if ob.parent and ob.parent.dupli_type != 'NONE':