Here you can find the source of putRGBfromHSB(final ByteBuffer pixels, final float[] hsb, int pixelSize)
public static void putRGBfromHSB(final ByteBuffer pixels, final float[] hsb, int pixelSize)
//package com.java2s; import java.nio.ByteBuffer; public class Main { public static void putRGBfromHSB(final ByteBuffer pixels, final float[] hsb, int pixelSize) { int idx = 0; for (int i = hsb.length / 3; --i >= 0;) { int r = 0, g = 0, b = 0; if (hsb[idx + 1] == 0) r = g = b = (int) (hsb[idx + 2] * 255.0f + 0.5f); else { float h = (hsb[idx + 0] - (float) Math.floor(hsb[idx + 0])) * 6.0f; float f = h - (float) Math.floor(h); float p = hsb[idx + 2] * (1.0f - hsb[idx + 1]); float q = hsb[idx + 2] * (1.0f - hsb[idx + 1] * f); float t = hsb[idx + 2] * (1.0f - (hsb[idx + 1] * (1.0f - f))); switch ((int) h) { case 0: r = (int) (hsb[idx + 2] * 255.0f + 0.5f); g = (int) (t * 255.0f + 0.5f); b = (int) (p * 255.0f + 0.5f); break; case 1: r = (int) (q * 255.0f + 0.5f); g = (int) (hsb[idx + 2] * 255.0f + 0.5f); b = (int) (p * 255.0f + 0.5f); break; case 2: r = (int) (p * 255.0f + 0.5f); g = (int) (hsb[idx + 2] * 255.0f + 0.5f); b = (int) (t * 255.0f + 0.5f); break; case 3: r = (int) (p * 255.0f + 0.5f); g = (int) (q * 255.0f + 0.5f); b = (int) (hsb[idx + 2] * 255.0f + 0.5f); break; case 4: r = (int) (t * 255.0f + 0.5f); g = (int) (p * 255.0f + 0.5f); b = (int) (hsb[idx + 2] * 255.0f + 0.5f); break; case 5: r = (int) (hsb[idx + 2] * 255.0f + 0.5f); g = (int) (p * 255.0f + 0.5f); b = (int) (q * 255.0f + 0.5f); break; }// w w w . j a v a2 s.c om } pixels.put((byte) r); pixels.put((byte) g); pixels.put((byte) b); if (pixelSize == 4) pixels.get(); idx += 3; } } }