Search code examples
javac++colorsbitmapjava-native-interface

JNI C++ to Java 32 bit image not showing properly


I have the following C++ code for JNI

And the following Java code to create a 32bit bufferedimage, the sizes are also received through JNI

Everything seems to work only that I have some weird colors in the image and I don't know how to get it right

Result of an image:


Solution

  • Isn't this just a mix in the order of the color components?

    I'm not familiar with any of these functions, but I believe that DIB_RGB_COLORS gives you the components in the “blue, green, red, reserved” order, whereas TYPE_4BYTE_ABGR is expecting the components in the “alpha, blue, green, red” order.