javaandroidgraphicsandroid-ndkbackport

How can I use BitmapRegionDecoder code in android 2.2.2 (Froyo)?


I was reading an answer to a different question on SO, in which @RomainGuy commented that one could (please correct me if I'm paraphrasing incorrectly) back-port code from later versions of android to earlier versions. Specifically, I am interested in back-porting code for BitmapRegionDecoder from Android version 2.3.3 (Gingerbread) to version 2.2.2 (Froyo).

I would have rather asked the question more generally as what is the best practice / what should be avoided when back-porting code from newer versions of Android to older versions, but stackoverflow hinted that my question might be closed as being too subjective.

Maybe if there is enough interest in the topic, this question could be "morphed" into a more general one..possibly a community wiki?

In any case, I would appreciate any insight into how this is done..whether specific to my use case, or more general advice. Do calls to native methods from within the java class complicate the matter (necessarily involving the NDK)?

If it is indeed possible (and reasonable) to cherry-pick and back-port code in this way, I think many would find it very useful to know how.


Solution

  • As @hackbod mentioned BitmapRegionDecoder is based on external skia library. Yet it's may be a benefit.

    Let's examine original source:

    P.S. I didn't actually dive deep in the code so please correct me if there's anything I overlooked.

    Update:

    Source code we need is located in following repositories on branches froyo-release and gingerbread-mr4-release: