public Object getDataElements(int rgb, Object pixel) { // Convert rgb to [0.0, 1.0] sRGB values. float[] rgbFloats = { ((rgb >> 16) & 0xff) / 255.0F, ((rgb >> 8) & 0xff) / 255.0F, ((rgb >> 0) & 0xff) / 255.0F }; // Convert from rgb to color space components. float[] data = cspace.fromRGB(rgbFloats); DataBuffer buffer = Buffers.createBuffer(transferType, pixel, getNumComponents()); int numColors = getNumColorComponents(); if (hasAlpha()) { float alpha = ((rgb >> 24) & 0xff) / 255.0F; /* If color model has alpha and should be premultiplied, multiply color space components with alpha value. */ if (isAlphaPremultiplied()) { for (int i = 0; i < numColors; i++) data[i] *= alpha; } // Scale the alpha sample to the correct number of bits. alpha *= (1 << (bits[numColors] - 1)); // Arrange the alpha sample in the output array. buffer.setElemFloat(numColors, alpha); } for (int i = 0; i < numColors; i++) { // Scale the color samples to the correct number of bits. float value = data[i] * (1 << (bits[i] - 1)); // Arrange the color samples in the output array. buffer.setElemFloat(i, value); } return Buffers.getData(buffer); }