Snaps the color value within the byte range (0-255) - Java 2D Graphics

Java examples for 2D Graphics:Color

Description

Snaps the color value within the byte range (0-255)

Demo Code


//package com.java2s;

public class Main {
    /**/*from w w  w.  j a  v  a2 s .c om*/
     * Snaps the color value within the byte range (0-255)
     * @param rgbavalue The value to snap.
     * @return The snapped value.
     */
    public static int colorSnap(int rgbavalue) {
        if (rgbavalue > 255)
            rgbavalue = 255;
        if (rgbavalue < 0)
            rgbavalue = 0;
        return rgbavalue;
    }
}

Related Tutorials