Convert pixel types from GL constants.

@param e The GL constant.

@return The value.
773794
public static JCGLPixelFormat pixelTypeFromGL(
    final int e)
  {
    switch (e) {
      case GL30.GL_UNSIGNED_INT_24_8:
        return JCGLPixelFormat.PIXEL_PACKED_UNSIGNED_INT_24_8;
      case GLES20.GL_UNSIGNED_SHORT_5_6_5:
        return JCGLPixelFormat.PIXEL_PACKED_UNSIGNED_SHORT_565;
      case GLES20.GL_UNSIGNED_SHORT_5_5_5_1:
        return JCGLPixelFormat.PIXEL_PACKED_UNSIGNED_SHORT_5551;
      case GLES20.GL_UNSIGNED_SHORT_4_4_4_4:
        return JCGLPixelFormat.PIXEL_PACKED_UNSIGNED_SHORT_4444;
      case GL12.GL_UNSIGNED_INT_10_10_10_2:
        return JCGLPixelFormat.PIXEL_PACKED_UNSIGNED_INT_1010102;
      case GL11.GL_UNSIGNED_SHORT:
        return JCGLPixelFormat.PIXEL_COMPONENT_UNSIGNED_SHORT;
      case GL11.GL_UNSIGNED_INT:
        return JCGLPixelFormat.PIXEL_COMPONENT_UNSIGNED_INT;
      case GL11.GL_UNSIGNED_BYTE:
        return JCGLPixelFormat.PIXEL_COMPONENT_UNSIGNED_BYTE;
      case GL11.GL_SHORT:
        return JCGLPixelFormat.PIXEL_COMPONENT_SHORT;
      case GL11.GL_INT:
        return JCGLPixelFormat.PIXEL_COMPONENT_INT;
      case GL11.GL_FLOAT:
        return JCGLPixelFormat.PIXEL_COMPONENT_FLOAT;
      case GL11.GL_BYTE:
        return JCGLPixelFormat.PIXEL_COMPONENT_BYTE;
      case GL30.GL_HALF_FLOAT:
        return JCGLPixelFormat.PIXEL_COMPONENT_HALF_FLOAT;
      default:
        throw new UnreachableCodeException();
    }
  }
114267
protected static int getBytesPerPixel(Bitmap.Config config) {
        if (config == Bitmap.Config.ARGB_8888) {
            return 4;
        } else if (config == Bitmap.Config.RGB_565) {
            return 2;
        } else if (config == Bitmap.Config.ARGB_4444) {
            return 2;
        } else if (config == Bitmap.Config.ALPHA_8) {
            return 1;
        }
        return 1;
    }
981488
public static int sameTagElNums(Element e) {
        Elements els = e.parent().getElementsByTag(e.tagName());
        return els.size();
    }
272866
public static int[] getRGB(BufferedImage image) {
		int[] pixels = getRGBArray(image);
		getRGB(image, pixels);
		return pixels;
	}
170028
public Double getValue(GriddedTile griddedTile, short pixelValue) {
		int unsignedPixelValue = getUnsignedPixelValue(pixelValue);
		Double value = getValue(griddedTile, unsignedPixelValue);
		return value;
	}
1022312
public int getColor(float v) {
/*
		v *= 255;
		int n = (int)v;
		float f = v-n;
		if (n < 0)
			return map[0];
		else if (n >= 255)
			return map[255];
		return ImageMath.mixColors(f, map[n], map[n+1]);
*/
		int n = (int)(v*255);
		if (n < 0)
			n = 0;
		else if (n > 255)
			n = 255;
		return map[n];
	}
426269
public static int pixelTypeToGL(
    final JCGLPixelFormat p)
  {
    switch (p) {
      case PIXEL_COMPONENT_BYTE:
        return GL11.GL_BYTE;
      case PIXEL_COMPONENT_FLOAT:
        return GL11.GL_FLOAT;
      case PIXEL_COMPONENT_INT:
        return GL11.GL_INT;
      case PIXEL_COMPONENT_SHORT:
        return GL11.GL_SHORT;
      case PIXEL_COMPONENT_UNSIGNED_BYTE:
        return GL11.GL_UNSIGNED_BYTE;
      case PIXEL_COMPONENT_UNSIGNED_INT:
        return GL11.GL_UNSIGNED_INT;
      case PIXEL_COMPONENT_UNSIGNED_SHORT:
        return GL11.GL_UNSIGNED_SHORT;
      case PIXEL_PACKED_UNSIGNED_INT_1010102:
        return GL12.GL_UNSIGNED_INT_10_10_10_2;
      case PIXEL_PACKED_UNSIGNED_SHORT_4444:
        return GLES20.GL_UNSIGNED_SHORT_4_4_4_4;
      case PIXEL_PACKED_UNSIGNED_SHORT_5551:
        return GLES20.GL_UNSIGNED_SHORT_5_5_5_1;
      case PIXEL_PACKED_UNSIGNED_SHORT_565:
        return GLES20.GL_UNSIGNED_SHORT_5_6_5;
      case PIXEL_COMPONENT_HALF_FLOAT:
        return GL30.GL_HALF_FLOAT;
      case PIXEL_PACKED_UNSIGNED_INT_24_8:
        return GL30.GL_UNSIGNED_INT_24_8;
    }

    throw new UnreachableCodeException();
  }
444116
public int getUnsignedPixelValue(BufferedImage image, int x, int y) {
		short pixelValue = getPixelValue(image, x, y);
		int unsignedPixelValue = getUnsignedPixelValue(pixelValue);
		return unsignedPixelValue;
	}
412188
private double doubleValue2Colors( double left, double right ) {
        return rgba( doubleValue( red( left ), red( right ) ), //
                        doubleValue( green( left ), green( right ) ), //
                        doubleValue( blue( left ), blue( right ) ), 1 );
    }
700695
@Pure
	@Inline(value = "(int) Math.round($1)", imported = {Math.class})
	public static int pix2pix(double pixelCoord) {
		return (int) Math.round(pixelCoord);
	}
213566
public Color getPixel(int x, int y) {
		predraw();
		GL.glReadPixels(x, screenHeight - y, 1, 1, SGL.GL_RGBA,
				SGL.GL_UNSIGNED_BYTE, readBuffer);
		postdraw();

		return new Color(translate(readBuffer.get(0)), translate(readBuffer
				.get(1)), translate(readBuffer.get(2)), translate(readBuffer
				.get(3)));
	}
755746
public static <T extends ImageGray<T>> T convertFromSingle(BufferedImage src, T dst, Class<T> type) {
		if (type == GrayU8.class) {
			return (T) convertFrom(src, (GrayU8) dst);
		} else if( GrayI16.class.isAssignableFrom(type) ) {
			return (T) convertFrom(src, (GrayI16) dst,(Class)type);
		} else if (type == GrayF32.class) {
			return (T) convertFrom(src, (GrayF32) dst);
		} else {
			throw new IllegalArgumentException("Unknown type " + type);
		}
	}
701148
private double valueToPixelValue(GriddedTile griddedTile, double value) {

		double pixelValue = value;

		if (griddedCoverage != null
				&& griddedCoverage.getDataType() == GriddedCoverageDataType.INTEGER) {

			pixelValue -= griddedCoverage.getOffset();
			pixelValue /= griddedCoverage.getScale();
			if (griddedTile != null) {
				pixelValue -= griddedTile.getOffset();
				pixelValue /= griddedTile.getScale();
			}

		}

		return pixelValue;
	}
896952
function getSizeInPixels(el, value) {
    if (/px$/i.test(value)) return parseFloat(value);
    var style = el.style.left, runtimeStyle = el.runtimeStyle.left;
    el.runtimeStyle.left = el.currentStyle.left;
    el.style.left = value;
    var result = el.style.pixelLeft;
    el.style.left = style;
    el.runtimeStyle.left = runtimeStyle;
    return result;
  }
369965
public short[] getPixelValues(BufferedImage image) {
		validateImageType(image);
		WritableRaster raster = image.getRaster();
		short[] pixelValues = getPixelValues(raster);
		return pixelValues;
	}
1344319
public short getPixelValue(BufferedImage image, int x, int y) {
		validateImageType(image);
		WritableRaster raster = image.getRaster();
		short pixelValue = getPixelValue(raster, x, y);
		return pixelValue;
	}
1019793
public static Object calculateValue(Expression e) {
		if (e instanceof Literal) {
			((Literal) e).computeConstant();
			switch (e.constant.typeID()) {
			case TypeIds.T_int: return e.constant.intValue();
			case TypeIds.T_byte: return e.constant.byteValue();
			case TypeIds.T_short: return e.constant.shortValue();
			case TypeIds.T_char: return e.constant.charValue();
			case TypeIds.T_float: return e.constant.floatValue();
			case TypeIds.T_double: return e.constant.doubleValue();
			case TypeIds.T_boolean: return e.constant.booleanValue();
			case TypeIds.T_long: return e.constant.longValue();
			case TypeIds.T_JavaLangString: return e.constant.stringValue();
			default: return null;
			}
		} else if (e instanceof ClassLiteralAccess) {
			return new ClassLiteral(Eclipse.toQualifiedName(((ClassLiteralAccess) e).type.getTypeName()));
		} else if (e instanceof SingleNameReference) {
			return new FieldSelect(new String(((SingleNameReference)e).token));
		} else if (e instanceof QualifiedNameReference) {
			String qName = Eclipse.toQualifiedName(((QualifiedNameReference) e).tokens);
			int idx = qName.lastIndexOf('.');
			return new FieldSelect(idx == -1 ? qName : qName.substring(idx+1));
		} else if (e instanceof UnaryExpression) {
			if ("-".equals(((UnaryExpression) e).operatorToString())) {
				Object inner = calculateValue(((UnaryExpression) e).expression);
				if (inner instanceof Integer) return - ((Integer) inner).intValue();
				if (inner instanceof Byte) return - ((Byte) inner).byteValue();
				if (inner instanceof Short) return - ((Short) inner).shortValue();
				if (inner instanceof Long) return - ((Long) inner).longValue();
				if (inner instanceof Float) return - ((Float) inner).floatValue();
				if (inner instanceof Double) return - ((Double) inner).doubleValue();
				return null;
			}
		}
		
		return null;
	}