Image and Texture
Image
An image class for loading, saving, and manipulating pixel data.
Uses Pillow for file I/O and stores pixel data as a numpy uint8 array.
Source code in ncca/ngl/image.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
height
property
The image height in pixels.
mode
property
The image colour mode.
width
property
The image width in pixels.
__init__(filename=None, width=0, height=0, mode=None)
Create an image, either from a file or as a blank canvas.
| Parameters: |
|
|---|
Source code in ncca/ngl/image.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
get_pixels()
Return the raw pixel data array.
Source code in ncca/ngl/image.py
136 137 138 | |
load(filename)
Load an image from file, converting unsupported modes.
| Returns: |
|
|---|
Source code in ncca/ngl/image.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
save(filename)
Save the image to file, format inferred from the extension.
| Returns: |
|
|---|
Source code in ncca/ngl/image.py
107 108 109 110 111 112 113 114 115 116 117 118 119 | |
set_pixel(x, y, r, g, b, a=255)
Set the pixel at (x, y) to the given colour.
| Parameters: |
|
|---|
| Raises: |
|
|---|
Source code in ncca/ngl/image.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
Texture
A texture class to load and create OpenGL textures.
Source code in ncca/ngl/opengl/texture.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
format
property
The OpenGL pixel format for the image mode, or 0 if unknown.
height
property
The texture image height in pixels.
internal_format
property
The OpenGL internal format for the image mode, or 0 if unknown.
width
property
The texture image width in pixels.
__init__(filename=None)
Create a texture, optionally loading an image file immediately.
Source code in ncca/ngl/opengl/texture.py
13 14 15 16 17 | |
get_pixels()
Return the raw pixel data as bytes.
Source code in ncca/ngl/opengl/texture.py
57 58 59 | |
load_image(filename)
Load an image file; returns True on success.
Source code in ncca/ngl/opengl/texture.py
53 54 55 | |
set_multi_texture(id)
Set the texture unit offset used when binding.
Source code in ncca/ngl/opengl/texture.py
86 87 88 | |
set_texture_gl()
Generate a texture ID and set the texture parameters.
Returns 0 (the OpenGL "not active" default) if the image is invalid.
Source code in ncca/ngl/opengl/texture.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |