ImageFFmpeg: scale

scale
  • Activates nearest scaling algorithm

Type: 

  • boolean
  • True = activate nearest scaling algorithm
  • False = don't activate nearest scaling algorithm
Note:
  • Video Texture width and height should be a power of 2.
  • If the Video Texture is not a power of 2, the graphics pipeline automatically rescales the texture to a power of 2.
     
  • Graphics pipeline doesn't always use the nearest scaling algorithm.
Power of 2:
  • 2 x 2
  • 4 x 4
  • 8 x 8
  • 16 x 16
  • 32 x 32
  • 64 x 64
  • 128 x 128
  • 256 x 256
  • 512 x 512
  • etc
  • And any combination.  128 x 512 is a power of 2.
Example:
  • A texture of 300 x 300 will be automatically rescaled by the graphics pipeline to 512 x 512.
  • A texture of 130 x 520 will be automatically rescaled by the graphics pipeline to 256 x 1024
Sample Code

###################### get the scaling status

#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
tex.source = bge.texture.ImageFFmpeg(imagePath)

# get the scaling status
status = tex.source.scale

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

# update the texture
tex.refresh(True)

Sample Code

###################### set the scaling status

#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
tex.source = bge.texture.ImageFFmpeg(imagePath)

# set the scaling status to True
tex.source.scale = True

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

# update the image
tex.refresh(True)