Java BufferedImage / Android Bitmap

I am developing a small library to work in both an Android application and a Java application. I need to use BufferedImage to get RGB values ​​from an image, but I cannot use BufferedImage in Andorid. And vice versa with Bitmap.

Is there a way to implement BufferedImage in Android or implement Bitmap in a working Java application?

thank

+3
source share
4 answers

Perhaps your library does not use any, but a specific interface that you define, which has all the necessary functions. Then, for the Android version, you implement the interface using the Bitmap object, and for the desktop version, you implement the interface using the BufferedImage. The caller who uses your library goes through the implementation of an interface that matches the platform that the caller uses, and your code should never worry about platform-specific materials.

Of course, whether this depends on it depends on how widely used image objects are in your library. If this is just a line or two of code that should read the image, this may not be a problem, and the reflection methods given in the other answers may be simpler.

+3
source

-, , , NoClassDefFoundError, . API- .

0

All Articles