
- Reloads the image.
- Uses the original image name/path to reload an image.
- Loads an image (original or new) using the image name/path.
imagePath:
- Path and name of the image.
- Type: string

###################### load an image
#import bge
import bge
# get the name of the image
# I'm using an image named Mona_Lisa.jpg
imageName = "Mona_Lisa.jpg"
# get image path
# Mona_Lisa.jpg is in same directory as saved blend
imagePath = bge.logic.expandPath('//' + imageName)
# get current scene
scene = bge.logic.getCurrentScene()
# get list of objects in scene
objList = scene.objects
# get object named Painting
obj = objList["Painting"]
# get matID for the obj named Painting
# I named the material Canvas
matID = bge.texture.materialID(obj, "MACanvas")
# get the texture
tex = bge.texture.Texture(obj, matID)
# get image used as the texture source
tex.source = bge.texture.ImageFFmpeg(imagePath)
# save ImageFFmpeg texture as an object variable
obj["Texture_ImageFFmpeg"] = tex
# display the image
tex.refresh(True)
###################### reload an image using the original name
#import bge
import bge
# get current scene
scene = bge.logic.getCurrentScene()
# get list of objects in scene
objList = scene.objects
# get object named Painting
obj = objList["Painting"]
# get the saved object variable
tex = obj["Texture_ImageFFmpeg"]
# reload the image
tex.source.reload()
# update the image
tex.refresh(True)
###################### load an new image with reload
#import bge
import bge
# get current scene
scene = bge.logic.getCurrentScene()
# get list of objects in scene
objList = scene.objects
# get object named Painting
obj = objList["Painting"]
# get the saved object variable
tex = obj["Texture_ImageFFmpeg"]
# the name of the new image to replace original image
imageName = "Vitruvian_Man.jpg"
## get image path
## Vitruvian_Man.jpg is in same directory as saved blend
imagePath = bge.logic.expandPath('//' + imageName)
# reload the texture
tex.source.reload(imagePath)
# update the texture
tex.refresh(True)