ImageViewport: capsize

capsize
  • set/get the maximum size of the source image

Type: 

  • list: [ width, height ]

width:
  • source resolution width in pixels.
  • Type:  integer
height:
  • source resolution height in pixels.
  • Type:  integer
Note:
  • capsize is the size of the source image.
  • capsize is not the size of the display that the source image is being displayed on.
Example:
  • capsize = 32 pixels by 32 pixels.
  • display size = 256 pixels by 256 pixels.
  • source image will be scaled to same size as display.
Sample Code

###################### get capsize of source image

# import bge module
import bge

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

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

# get object to render to
# my object is named Security_Monitor
obj = objList["Security_Monitor"]

# get the Security_Monitor material ID
# Name of my render material is Screen
matID = bge.texture.materialID(obj, "MAScreen")

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

# get the texture image source
viewport_texture.source = bge.texture.ImageViewport()

# get capsize
size = viewport_texture.source.capsize

# save as an object property
obj["image_viewport"] = viewport_texture

# update texture
viewport_texture.refresh(True)

Sample Code

###################### set capsize of source image

# import bge module
import bge

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

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

# get object to render to
# my object is named Security_Monitor
obj = objList["Security_Monitor"]

# get the Security_Monitor material ID
# Name of my render material is Screen
matID = bge.texture.materialID(obj, "MAScreen")

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

# get the texture image
viewport_texture.source = bge.texture.ImageViewport()

# set capsize
viewport_texture.source.capsize = [ 256, 256 ]

# save as an object property
obj["image_viewport"] = viewport_texture

# update texture
viewport_texture.refresh(True)