ImageMirror: size

size
  • Returns the source image size.

Return Type:

  • integer list [ width, height ]

width:

  • Type: integer
  • pixel width of the image.
height:
  • Type: integer
     
  • pixel height of the image.
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.
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 source image size

# import bge module
import bge

# get current scene
scene = bge.logic.getCurrentScene()

# get list of objects in scene
objList = scene.objects

# get object named Mirror
obj = objList["Mirror"]

# get the mirror material ID
# Name of my Mirror material is Reflect
matID = bge.texture.materialID(obj, "MAReflect")

# get a list of the cameras
camList = scene.cameras

# get the camera named PlayerOne
cam = camList["PlayerOne"]
           
# texture I'm using for the mirror is in first texture channel
texChannel = 0

# get the texture
mirror = bge.texture.Texture(obj, matID, texChannel)

# get the mirror source
mirror.source = bge.texture.ImageMirror(scene, cam, obj, matID)

# get image size
image_size = mirror.source.size

# save mirror as an object variable
obj["Mirror"] = mirror

# update mirror
mirror.refresh(True)