ImageBuff: flip

flip
  • set/get whether or not the image is flipped vertically (upside down)

Type: 

  • boolean
  • True = flip image
  • False = don't flip image
Sample Code

###################### get if image is flipped

#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 matID for the obj named Painting
# I named the material Canvas
matID = bge.texture.materialID(obj, "MACanvas")

# get the 1st texture on object named Painting
portrait = bge.texture.Texture(obj, matID)

# 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 image as an ImageFFmpeg
image = bge.texture.ImageFFmpeg(imagePath)

# load image into a bgl buffer
image_buffer = bge.texture.imageToArray(image, 'RGB')

# get image size
image_size = image.size

# use ImageBuff as the source
portrait.source = bge.texture.ImageBuff()

# get status of image flip
status = portrait.source.flip

# load the image from the buffer into ImageBuff
portrait.source.load(image_buffer, image_size[0], image_size[1])

# save as an object variable
obj["Portrait"] = portrait

# display the image
portrait.refresh(True)

Sample Code

###################### set if image is flipped

#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 matID for the obj named Painting
# I named the material Canvas
matID = bge.texture.materialID(obj, "MACanvas")

# get the 1st texture on object named Painting
portrait = bge.texture.Texture(obj, matID)

# 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 image as an ImageFFmpeg
image = bge.texture.ImageFFmpeg(imagePath)

# load image into a bgl buffer
image_buffer = bge.texture.imageToArray(image, 'RGB')

# get image size
image_size = image.size

# use ImageBuff as the source
portrait.source = bge.texture.ImageBuff()

# Flip the image
portrait.source.flip = True

# load the image from the buffer into ImageBuff
portrait.source.load(image_buffer, image_size[0], image_size[1])

# save as an object variable
obj["Portrait"] = portrait

# display the image
portrait.refresh(True)