Adjust Transparency of Non-zero Cells of an Image?

Is there a way to affect all the non-zero cells in the transparency column (Column D) of an image without changing the cells with zero in them?

I would like to add amounts to the non-zero cells (thereby changing their transparency / opaqueness) without affecting the cells that have a zero in them (i.e., the cells in the background portion of the image in this instance).

here's a way to do that

you can change the 10 in the list block to the value you want the non-zero values to change to. This only affects the alpha channel.

1 Like

Slighty alternative approach - It was an interesting exercise :slight_smile:

JFI Page 63 of the manual gave me the info on how to do it

This was very helpful. I wanted to affect the transparency of the image (a bouquet of flowers in the illustration below) without affecting the background pixels. Thanks!



And for completeness say I just tried a non-map method


There's really no need to construct a new list in newPixels. (Insert rant about camel case here.) PIXELS OF COSTUME already gives you a new list (contrary to what I thought until I tried it), so instead of putting an ADD block in the loop, you can just do

1 Like

I was thinking whether we could achieve the end result using hyperblocks approach and I think this would do what you want as well


@cymplecy That works for subtraction and is much faster. It doesn't work for addition, because the background pixels are changed from 0 (completely transparent) to opaque (a value of 50 in this instance), resulting in a gray square surrounding the image. That would present a problem for creation of a bi-directional transparency / opacity slider (for example). However, one work-around might be to simply reset the image to its original state, and then always subtract. This seems to work because zero is at the lower end of the transparency range. Subtracting 100 from 0 in the alpha column seems to result in 0 (and not "- 100").

I like the hyperblock solution better because it is faster and simpler. Thanks for the assist!

@cymplecy The hyperblock method is so fast that even resetting the image each time doesn't perceptibly slow the movement of the transparency slider. Thanks!