Can I use Android SDK classes in a desktop application?
I have some android.graphics.Bitmap
data saved to a file that I want to manipulate in a desktop application. The data is generated by a third party application, so I can't modify the app to save the data as png or jpeg.
I am wondering if I can import the android SDK jar into a java desktop project so I can use the android.graphics.Bitmap and android.graphics.BitmapFactory classes? I have tried adding android.jar from th开发者_开发知识库e SDK but when I try to call the BitmapFactory.decodeByteArray()
method I get a runtime exception ("Stub!").
Please help.
If I can't import the SDK jar, does anybody know the format of the bitmaps that android uses?
The Android SDK is for Android's Dalvik VM, not the the normal JVM, so that is not going to work.
Since it is a bitmap, the data should be stored in a continuous list of Red, Green, and Blue pixels (the order of the colors can vary, there might also be alpha.)
So this might be an image: [FF][00][00][00][FF][00][00][FF][00][FF][00][00]
Assuming that image was stored in RGB format and was defined as being two pixels wide (the pitch) then it would be a 2x2 px image that represented a tiny red and green checkerboard pattern.
Your app might be exporting the width/height of the image and it might not. If it isn't you'll need to determine the width in order to get a proper image.
精彩评论