Java examples for javax.microedition.lcdui:Graphics
opaque Image micro edition
import javax.microedition.lcdui.Graphics; import javax.microedition.lcdui.Image; public class Main{ public static Image opaqueImage(Image sourceImage, Image __destImage, int prcSrcToDest) { if (prcSrcToDest > 100) { prcSrcToDest = 100;//from ww w .j a v a 2s.c o m } else if (prcSrcToDest < 0) { prcSrcToDest = 0; } int imageWidth = sourceImage.getWidth(); int imageHeight = sourceImage.getHeight(); int[] rgbData = new int[imageWidth * imageHeight]; sourceImage.getRGB(rgbData, 0, imageWidth, 0, 0, imageWidth, imageHeight); int[] rgbDest = new int[imageWidth * imageHeight]; __destImage.getRGB(rgbDest, 0, imageWidth, 0, 0, imageWidth, imageHeight); int currY, r, g, b, currPoint, destPoint, prcDestToSrc = 100 - prcSrcToDest; for (int y = 0; y < imageHeight; y++) { currY = y * imageWidth; for (int x = 0; x < imageWidth; x++) { currPoint = rgbData[currY + x]; destPoint = rgbDest[currY + x]; b = ((currPoint & 0xff0000) * prcSrcToDest + (destPoint & 0xff0000) * prcDestToSrc) / 100 & 0xff0000; g = ((currPoint & 0xff00) * prcSrcToDest + (destPoint & 0xff00) * prcDestToSrc) / 100 & 0xff00; r = ((currPoint & 0xff) * prcSrcToDest + (destPoint & 0xff) * prcDestToSrc) / 100 & 0xff; rgbData[currY + x] = r | g | b; } } return Image .createRGBImage(rgbData, imageWidth, imageHeight, false); } }