Skip to content

Instantly share code, notes, and snippets.

@hysysk
Created March 11, 2020 08:27
Show Gist options
  • Save hysysk/eefd14eba76747932ef88c54f5b40426 to your computer and use it in GitHub Desktop.
Save hysysk/eefd14eba76747932ef88c54f5b40426 to your computer and use it in GitHub Desktop.
To export a black and white color layer with blend mode "Screen".
PImage img = loadImage("noise_bw.png");
PImage out = createImage(img.width, img.height, ARGB);
img.loadPixels();
out.loadPixels();
for(int i=0; i<img.width; i++) {
for(int j=0; j<img.height; j++) {
color c = img.pixels[j+i*img.width];
float a = brightness(c);
out.pixels[j+i*img.width] = color(255, 255, 255, a);
}
}
out.updatePixels();
out.save("noise.png");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment