+def pixels_to_rgba(pixels):
+ return (int(p*255) for p in pixels)
+
+def pixels_to_rgb(pixels):
+ for i in range(0, len(pixels), 4):
+ yield int(pixels[i]*255)
+ yield int(pixels[i+1]*255)
+ yield int(pixels[i+2]*255)
+
+def pixels_to_rgb_invert(pixels, mask):
+ for i in range(0, len(pixels), 4):
+ r = int(pixels[i]*255)
+ yield 255-r if mask&1 else r
+ g = int(pixels[i+1]*255)
+ yield 255-g if mask&2 else g
+ b = int(pixels[i+2]*255)
+ yield 255-b if mask&4 else b