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

Method applyMask

CodenameOne/src/com/codename1/ui/Image.java:1148–1175  ·  view source on GitHub ↗
(Object mask, int x, int y)

Source from the content-addressed store, hash-verified

1146 ///
1147 /// image masked based on the given object
1148 public Image applyMask(Object mask, int x, int y) {
1149 int[] rgb = getRGB();
1150 byte[] maskData = ((IndexedImage) mask).getImageDataByte();
1151 int mWidth = ((IndexedImage) mask).getWidth();
1152 int mHeight = ((IndexedImage) mask).getHeight();
1153 int imgWidth = getWidth();
1154 int aWidth = imgWidth - x;
1155 int aHeight = getHeight() - y;
1156 if (aWidth > mWidth) {
1157 aWidth = mWidth;
1158 }
1159 if (aHeight > mHeight) {
1160 aHeight = mHeight;
1161 }
1162
1163 for (int xPos = 0; xPos < aWidth; xPos++) {
1164 for (int yPos = 0; yPos < aHeight; yPos++) {
1165 int aX = x + xPos;
1166 int aY = y + yPos;
1167 int imagePos = aX + aY * imgWidth;
1168 int maskAlpha = maskData[aX + aY * mWidth] & 0xff;
1169 maskAlpha = (maskAlpha << 24) & 0xff000000;
1170 rgb[imagePos] = (rgb[imagePos] & 0xffffff) | maskAlpha;
1171
1172 }
1173 }
1174 return createImageWithRgbCache(rgb, imgWidth, getHeight());
1175 }
1176
1177 /// Applies the given alpha mask onto this image and returns the resulting image
1178 /// see the createMask method for indication on how to convert an image into an alpha

Callers 13

applyMaskAutoScaleMethod · 0.95
generateFadeImageMethod · 0.95
measureImageEncodeMethod · 0.95
testApplyMaskMethod · 0.95
postProcessMethod · 0.45
paintMethod · 0.45
invoke8Method · 0.45
measureApplyMaskMethod · 0.45

Calls 12

getRGBMethod · 0.95
getWidthMethod · 0.95
getHeightMethod · 0.95
getMethod · 0.95
allocaByteMethod · 0.95
arraycopyMethod · 0.95
getImageDataByteMethod · 0.80
getWidthMethod · 0.65
getHeightMethod · 0.65