I need to transmit an array of colors from Java to OpenCL and I just wondered to what type they are best translated. In some languages a Color is just a 32 bit integer, the Java docs sometimes hint it is as well but I never see this explicitly mentioned. As OpenCL only knows the basic types I wanted to translate the color array to an integer array, have it processed and next translate it back. Does it matter whether it is awt Color or javaFX color?
Thank you for your time.
If the color is a 32 bit integer, it is important to know how that integer is encoded.
RGB(A) is an encoding into a 32 bit integer, the first 8 bits are the Red intensity, the next 8 bits are the Green intensity, the next 8 bits are the Blue intensity, and the last 8 bits (if used) is a transparency.
However, that 32 bit integer might encode a completely different color, like a CMYK color, or a color out of a different color system.
There's no magic to encoding color in a 32 bit integer, but there's no standard encoding which can encode every color, and there's no room in the 32 bit integer to specify which encoding was used. So, no, there is no general solution.
Once you know the encoding that is required, or the encoding you will choose, that encoding will tell you if you can pack it into a 32 bit integer, and what the packing order and other details of setting the bits in that integer entail.