I am developing a little library to work in both Android application and Java desktop application. I need to use BufferedImage to get RGB values from an image, but I can't use BufferedImage in Andorid. And viceversa with Bitmap.
Is there any way to implement BufferedImage in Android or to implement Bitmap in the Java desktop application??
Thanks
You could have your library not use either one, but some interface that you define that has all of the functions you need. Then for the Android version, you implement the interface using a Bitmap object, and for the desktop version, you implement the interface with a BufferedImage. The caller that uses your library passes in the implementation of the interface that corresponds to the platform the caller is using, and your code doesn't ever have to worry about platform specific stuff.
Of course, whether or not this is worth the effort depends on how extensively the image objects are used in your library. If it's just a line or two of code that needs to read the image, it may not be worth the trouble, and the reflection methods given in other answers might be easier.