2727import java .awt .Color ;
2828import java .awt .image .BufferedImage ;
2929import java .io .Serial ;
30- import java .util .SplittableRandom ;
30+ import java .util .random . RandomGenerator ;
3131
3232import static pixelitor .gui .GUIText .OPACITY ;
3333import static pixelitor .utils .ImageUtils .isGrayscale ;
@@ -69,18 +69,15 @@ public AddNoise() {
6969
7070 @ Override
7171 public BufferedImage transform (BufferedImage src , BufferedImage dest ) {
72- SplittableRandom rand = paramSet .getLastSeedSRandom ();
72+ RandomGenerator rand = paramSet .getLastSeedSRandom ();
7373
74- if (isGrayscale (src )) {
75- return addNoiseToGray (src , dest , rand );
76- }
77-
78- boolean coverageAnim = method .getValue () == METHOD_COVERAGE_ANIM ;
79- return addNoiseToRGB (src , dest , coverageAnim , rand );
74+ return isGrayscale (src )
75+ ? addNoiseToGray (src , dest , rand )
76+ : addNoiseToRGB (src , dest , rand );
8077 }
8178
82- private BufferedImage addNoiseToRGB (BufferedImage src , BufferedImage dest ,
83- boolean coverageAnim , SplittableRandom rand ) {
79+ private BufferedImage addNoiseToRGB (BufferedImage src , BufferedImage dest , RandomGenerator rand ) {
80+ boolean coverageAnim = method . getValue () == METHOD_COVERAGE_ANIM ;
8481 int [] srcPixels = ImageUtils .getPixels (src );
8582 int [] destPixels = ImageUtils .getPixels (dest );
8683 int numPixels = destPixels .length ;
@@ -124,8 +121,8 @@ private BufferedImage addNoiseToRGB(BufferedImage src, BufferedImage dest,
124121 }
125122
126123 if (!coverageAnim ) {
127- // If coverage animation isn't a requirement, then it is faster
128- // to generate the random values only here, for the covered pixels.
124+ // if coverage animation isn't a requirement, then it is faster
125+ // to generate the random values only here, for the covered pixels
129126 randomInt = rand .nextInt ();
130127 }
131128
@@ -135,11 +132,11 @@ private BufferedImage addNoiseToRGB(BufferedImage src, BufferedImage dest,
135132
136133 if (fullOpacity ) {
137134 // if we have full saturation (the default), then we can
138- // just use the random pixel as it is - if the opacity is also 100.
135+ // just use the random pixel as it is - if the opacity is also 100
139136 destPixels [i ] = randomInt ;
140137 } else {
141- // ...or mix the random pixel with the source according to
142- // the opacity
138+ // ...or mix the random pixel with the source
139+ // according to the opacity
143140 destPixels [i ] = ImageMath .mixColors (opacity , srcRGB , randomInt );
144141 }
145142 } else { // desaturate the random pixel
@@ -167,7 +164,7 @@ private BufferedImage addNoiseToRGB(BufferedImage src, BufferedImage dest,
167164 }
168165
169166 private BufferedImage addNoiseToGray (BufferedImage src , BufferedImage dest ,
170- SplittableRandom rand ) {
167+ RandomGenerator rand ) {
171168 byte [] srcPixels = ImageUtils .getGrayPixels (src );
172169 byte [] destPixels = ImageUtils .getGrayPixels (dest );
173170
0 commit comments