Image: handle loading of images
_REF
Image: handle loading of images
-
class pymt.core.image.Image(arg, **kwargs)
Bases: pymt.baseobject.BaseObject
Load an image, and store the size and texture.
| Parameters : |
- arg : can be str or Texture or Image object
A string is interpreted as a path to the image that should be loaded.
You can also provide a texture object or an already existing image object.
In the latter case, a real copy of the given image object will be
returned.
- keep_data : bool, default to False
Keep the image data when texture is created
- opacity : float, default to 1.0
Opacity of the image
- scale : float, default to 1.0
Scale of the image
- anchor_x : float, default to 0
X anchor
- anchor_y : float, default to 0
Y anchor
- texture_rectangle : bool, default to True
Use rectangle texture is available (if false, will use the nearest
power of 2 size for texture)
- texture_mipmap : bool, default to False
Create mipmap for the texture
|
-
draw()
Draw the image on screen
-
filename
Get/set the filename of image
-
get_texture(*args, **kwargs)
Retreive the texture of image
@deprecated: use self.texture instead.
-
image
Get/set the data image object
-
static load(filename, **kwargs)
Load an image
| Parameters : |
- filename : str
Filename of the image
- keep_data : bool, default to False
Keep the image data when texture is created
|
-
read_pixel(x, y)
For a given local x/y position, return the color at that position.
Warning
This function can be used only with images loaded with
keep_data=True keyword. For examples
m = Image.load('image.png', keep_data=True)
color = m.read_pixel(150, 150)
| Parameters : |
- x : int
Local x coordinate of the pixel in question.
- y : int
Local y coordinate of the pixel in question.
|
-
texture
Texture of the image
-
class pymt.core.image.ImageData(width, height, mode, data)
Bases: object
Container for data image : width, height, mode and data.
Warning
Only RGB and RGBA mode are allowed.