List of usage examples for javafx.scene.image PixelWriter setColor
public void setColor(int x, int y, Color c);
From source file:net.rptools.tokentool.util.ImageUtil.java
private static Image clipImageWithMask(Image imageSource, Image imageMask) { int imageWidth = (int) imageMask.getWidth(); int imageHeight = (int) imageMask.getHeight(); WritableImage outputImage = new WritableImage(imageWidth, imageHeight); PixelReader pixelReader_Mask = imageMask.getPixelReader(); PixelReader pixelReader_Source = imageSource.getPixelReader(); PixelWriter pixelWriter = outputImage.getPixelWriter(); for (int readY = 0; readY < imageHeight; readY++) { for (int readX = 0; readX < imageWidth; readX++) { Color pixelColor = pixelReader_Mask.getColor(readX, readY); if (pixelColor.equals(Color.TRANSPARENT)) pixelWriter.setColor(readX, readY, pixelReader_Source.getColor(readX, readY)); }/* w ww. j a v a 2 s . c om*/ } return outputImage; }
From source file:net.rptools.tokentool.util.ImageUtil.java
private static Image processMagenta(Image inputImage, int colorThreshold, boolean overlayWanted) { int imageWidth = (int) inputImage.getWidth(); int imageHeight = (int) inputImage.getHeight(); WritableImage outputImage = new WritableImage(imageWidth, imageHeight); PixelReader pixelReader = inputImage.getPixelReader(); PixelWriter pixelWriter = outputImage.getPixelWriter(); for (int readY = 0; readY < imageHeight; readY++) { for (int readX = 0; readX < imageWidth; readX++) { Color pixelColor = pixelReader.getColor(readX, readY); if (isMagenta(pixelColor, COLOR_THRESHOLD) == overlayWanted) pixelWriter.setColor(readX, readY, Color.TRANSPARENT); else//w w w .j ava2 s.c o m pixelWriter.setColor(readX, readY, pixelColor); } } return outputImage; }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param imgRect/* w ww .ja va 2s. c o m*/ * @param iRapport * @return image transforme Mercator */ private static Image imgTransformationImage(Image imgRect, int iRapport) { int iLargeur = (int) imgRect.getWidth() / iRapport; int iHauteur = iLargeur / 2 / iRapport; WritableImage imgMercator = new WritableImage(iLargeur, iHauteur); PixelReader prRect = imgRect.getPixelReader(); PixelWriter pwMercator = imgMercator.getPixelWriter(); for (int i = 0; i < iLargeur; i++) { for (int j = 0; j < iHauteur; j++) { double phi = Math.asin(2.d * (iHauteur / 2.d - j) / iHauteur); int y2 = (int) (iHauteur * iRapport * (0.5d - phi / Math.PI)); if (y2 >= iHauteur * iRapport) { y2 = iHauteur * iRapport - 1; } Color clPixel = prRect.getColor(i * iRapport, y2 * iRapport); pwMercator.setColor(i, j, clPixel); } } return imgMercator; }