Java Pixel pixelRange(int p)

Here you can find the source of pixelRange(int p)

Description

Utility method to limit the value within [0,255] range

License

Open Source License

Parameter

Parameter Description
p Input value

Return

Limited value

Declaration

public static int pixelRange(int p) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from  w  w w .j  a v  a2 s  . c  o m*/
     * Utility method to limit the value within [0,255] range
     * 
     * @param p Input value
     * @return Limited value
     */
    public static int pixelRange(int p) {
        return ((p > 255) ? 255 : (p < 0) ? 0 : p);
    }

    /**
     * Utility method to limit the value within [0,255] range
     * 
     * @param p Input value
     * @return Limited value
     */
    public static int pixelRange(double p) {
        return ((p > 255) ? 255 : (p < 0) ? 0 : (int) p);
    }
}

Related

  1. pixel_distance(int x1, int y1, int x2, int y2)
  2. pixelSize(double lat, double lng, int zoom)
  3. pixelSpacing(int n)
  4. pixelsPerPanel(int n)
  5. pixelValuesEqual(final double num1, final double num2)