We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi all,
I'm struggling to find a way to make a part of an image created with copy() transparent. The images are preloaded into an array in setup(). I don't display the original images. I loop through the loaded images in draw() and use copy() to create a resized slice of the images. Is there a way to add transparency to these slices? I could also make the original transparent because it isn't displayed anyway. I tried using tint() in setup before loading but that doesn't work.
Any help is highly appreciated, best, Danielle.
Answers
The PImage class has a set() function that takes a color. That color can contain an alpha value. If that's not working, please post an MCVE showing exactly what you're doing.
Reference for the set() function: https://www.processing.org/reference/PImage_set_.html
color
should be made transparent on those PImage objects.#000000
found to0
.Hi guys, thanks for your answers. The thing is that I want to set alpha for a picture... Here is some very simplified code to illustrate:
So I want to set the copied part, the entire image strip, to a transparency of 10% for example. As I explained above I could even manipulate the originals as they are not shown. But I can't get that to work either. Thanks in advance for your help, best, danielle.
Use loadPixels(), iterate on the pixels[] array, set the high byte of each entry to the alpha value of your choice.
Thanks FhiLho, what is the high byte?
See http://forum.processing.org/two/discussion/8086/what-is-a-color-in-processing#latest in the Common Questions categtory...