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.
source