destroy_image¶
MiniLibX: mlx_destroy_image
Frees an image's pixels straight away.
Parameters¶
| Name | Type | Description |
|---|---|---|
mlx |
Mlx |
The connection from init |
img |
Image |
The image to free |
Returns¶
None.
Notes¶
- After this,
get_data_addrandput_image_to_windowraiseRuntimeError: image is destroyedfor this image. - Destroying an image twice is harmless.
- You usually don't need it. Python frees an image automatically once nothing refers to it. Use it to release a big image at a specific moment, or to keep MiniLibX-style code unchanged.
- Images already drawn in a window stay there. The window has its own copy of the pixels.
Example¶
splash, _, _ = malibx.xpm_file_to_image(mlx, "splash.xpm")
malibx.put_image_to_window(mlx, win, splash, 0, 0)
malibx.destroy_image(mlx, splash) # the window keeps showing it