Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def invert(image, invert_r = True, invert_g = True, invert_b = True, invert_a = True):
- import numpy
- pixels = numpy.empty(len(image.pixels), dtype=numpy.float32)
- image.pixels.foreach_get(pixels)
- if invert_r: pixels[0::4] = 1 - pixels[0::4]
- if invert_g: pixels[1::4] = 1 - pixels[1::4]
- if invert_b: pixels[2::4] = 1 - pixels[2::4]
- if invert_a: pixels[3::4] = 1 - pixels[3::4]
- image.pixels.foreach_set(pixels)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement