ImageFFmpeg: image

image
  • Returns the image data.

Return Type: 

  • integer list [r,g,b,a] for every pixel in the image.

a:

  • alpha color channel
  • Type:  integer
  • Range: 0 to 255
b:
  • blue color channel
  • Type:  integer
  • Range: 0 to 255
g:
  • green color channel
  • Type:  integer
  • Range: 0 to 255
r:
  • red color channel
  • Type:  integer
  • Range: 0 to 255
Sample Code

###################### get the image data

#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)

# get the image data
data = tex.source.image

# save ImageFFmpeg texture as an object variable
obj["Texture_ImageFFmpeg"] = tex

# display the image
tex.refresh(True)