Java BufferedImage Operation texture2D(BufferedImage normalMap, int x, int y)

Here you can find the source of texture2D(BufferedImage normalMap, int x, int y)

Description

Acts like GLSL function of same name

License

GNU General Public License

Parameter

Parameter Description
x a parameter
y a parameter
normalMap a parameter

Declaration

private static float[] texture2D(BufferedImage normalMap, int x, int y) 

Method Source Code

//package com.java2s;
/*//  w ww . jav a2s  . c  om
CCH World Factory - GPL
    
Copyright (C) 2014 Christopher Collin Hall
email: explosivegnome@yahoo.com
    
CCH World Factory - GPL is distributed under the GNU General Public 
License (GPL) version 3. A non-GPL branch of the CCH World Factory 
also exists. For non-GPL licensing options, contact the copyright 
holder, Christopher Collin Hall (explosivegnome@yahoo.com). 
    
CCH World Factory - GPL is free software: you can redistribute it 
and/or modify it under the terms of the GNU General Public License 
as published by the Free Software Foundation, either version 3 of 
the License, or (at your option) any later version.
    
CCH World Factory - GPL is distributed in the hope that it will be 
useful, but WITHOUT ANY WARRANTY; without even the implied warranty 
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
    
You should have received a copy of the GNU General Public License
along with CCH World Factory - GPL.  If not, see 
<http://www.gnu.org/licenses/>.
    
*/

import java.awt.image.BufferedImage;

public class Main {
    /**
     * Acts like GLSL function of same name
     * @param x
     * @param y
     * @param normalMap
     * @return 
     */
    private static float[] texture2D(BufferedImage normalMap, int x, int y) {
        int argb = normalMap.getRGB(x, y);
        float[] vec4 = new float[4];
        vec4[0] = ((argb >> 16) & 0xFF) / 255f;
        vec4[1] = ((argb >> 8) & 0xFF) / 255f;
        vec4[2] = ((argb) & 0xFF) / 255f;
        vec4[3] = ((argb >> 24) & 0xFF) / 255f;
        return vec4;
    }
}

Related

  1. smaller(final BufferedImage src, final int radius, final int opaqueLimit)
  2. stitchImages(BufferedImage[] images, int[] relX)
  3. switchAxes(BufferedImage img)
  4. symmetrifyY(BufferedImage image, boolean useFirstHalfImage, boolean flipVertical)
  5. testNeighbours(BufferedImage source, int x, int y, boolean alpha)
  6. thresholdImage(BufferedImage image, int threshold)
  7. tile(BufferedImage source, Rectangle r, GraphicsConfiguration conf)
  8. tileStretchPaint(Graphics g, Component component, BufferedImage image, Insets insets)
  9. tilt(BufferedImage image, double angle)