MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / modifyAlpha

Method modifyAlpha

CodenameOne/src/com/codename1/ui/Image.java:1362–1383  ·  view source on GitHub ↗
(byte alpha)

Source from the content-addressed store, hash-verified

1360 /// @return Translucent/Opaque image based on the alpha value and the pixels of
1361 /// this image
1362 public Image modifyAlpha(byte alpha) {
1363 int w = getWidth();
1364 int h = getHeight();
1365 int size = w * h;
1366 int[] arr = getRGB();
1367 if (isSimdOptimizationsEnabled() && size >= 16) {
1368 int alphaInt = (((int) alpha) << 24) & 0xff000000;
1369 replaceAlphaPreserveTransparentSimd(arr, 0, alphaInt, size);
1370 } else {
1371 int alphaInt = (((int) alpha) << 24) & 0xff000000;
1372 for (int iter = 0; iter < size; iter++) {
1373 int currentAlpha = (arr[iter] >> 24) & 0xff;
1374 if (currentAlpha != 0) {
1375 arr[iter] = (arr[iter] & 0xffffff) | alphaInt;
1376 }
1377 }
1378 }
1379 Image i = createImageWithRgbCache(arr, w, h);
1380 i.opaqueTested = true;
1381 i.opaque = false;
1382 return i;
1383 }
1384
1385 /// Creates a new image instance with the alpha channel of opaque
1386 /// pixels within the image using the new alpha value. Transparent (alpha == 0)

Callers 10

getDragImageMethod · 0.95
testModifyAlphaMethod · 0.95
paintComponentMethod · 0.45
invoke8Method · 0.45
measureModifyAlphaMethod · 0.45
measureImageEncodeMethod · 0.45

Calls 8

getWidthMethod · 0.95
getHeightMethod · 0.95
getRGBMethod · 0.95
allocateRgbArrayMethod · 0.95

Tested by 6

testModifyAlphaMethod · 0.76
measureModifyAlphaMethod · 0.36
measureImageEncodeMethod · 0.36