Could you use setPixels(int[]) instead?
On Mon, Jul 9, 2012 at 9:52 AM, Latimerius <[email protected]>wrote: > On Mon, Jul 9, 2012 at 6:16 PM, Nobu Games <[email protected]> > wrote: > > As far as I know that allocated array > > resides on the native heap until it is released and copied back to Java. > > That probably only happens when you alter the pixel data from Java. Which > > means that the get and setPixel methods must be really slow because in > worst > > case they can cause heavy copy operations between JVM and native code for > > each access. > > I tried in the meantime to fill my large Bitmap by calling setPixel() > on each of its pixels and the running time is in the order of tens > seconds. > > > The only other option that comes to my mind for speeding up things would > be > > writing some NDK code and using a PNG library for encoding the pixel > data in > > native code. Passing that int array to that native code is > straightforward. > > With a trick you can even access the original Java int array directly > > without waiting for a copy. This is possible with the JNI function > > GetPrimitiveArrayCritical. There is no guarantee, though that direct > access > > works in any case. The documentation of that function explains the limits > > pretty well. > > I don't use NDK in this app, was meant to be pure Java, however as > there are other (performance) problems with bulk GL data handling that > apparently cannot be solved without native code, I might consider NDK > as well. > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Romain Guy Android framework engineer [email protected] -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

