I feel your pain, when I do a generic flood fill it's taking 10s of seconds to walk through the array of pixels. I'm hoping memory access time will be reduced dramatically on a real device, or if it isn't jni is supported in some fashion.
On Mar 30, 11:10 am, saurabh <[EMAIL PROTECTED]> wrote: > On Mar 30, 7:08 pm, David Given <[EMAIL PROTECTED]> wrote: > > > saurabh wrote: > > > [...] > > > > The getPixel > > > function seems to be taking approx 1/100 of a second. Similarly, > > > checking whether each pixel satisfies the condition and then copying > > > it to Bitmap B also takes approx 1/100 second. Therefore, performing > > > these 2 operations for 547*450 = 246150 pixels takes a lot of time. Is > > > there any way to do this faster? > > > I'd be inclined to copy all the pixel data out of the Bitmap into a > > int[] array of pixels; process it in-place; and then copy it all back in > > again. That way the heavy lifting --- the image processing --- occurs > > using simple array accesses, which should be way faster than doing > > method calls on Bitmap. > > Thanks. That makes sense. The getPixels() and setPixels() calls are > quite fast and I need to call them only once. However, iterating over > the int[] array and checking each value is taking a lot of time. I've > reduced the time of the app by half but that is just not good enough. > > > However... > > > > I hope to use this for processing > > > each frame of a video in real-time. So, processing each picture must > > > not take more than a 1/20 of a second. > > > ...not a chance! > > > Hopefully this will be improved considerably when the JIT goes in, but > > right now simply filling an array of the right size with zeroes takes > > over a second. > > > (I recently had to do something similar; I eventually got around it by > > pushing all the image processing off into native code via JNI, which of > > course is not officially supported and probably not a good choice unless > > you really need it.) > > > -- > > ┌─── dg@cowlark.com ─────http://www.cowlark.com───── > > │ "I have always wished for my computer to be as easy to use as my > > │ telephone; my wish has come true because I can no longer figure out > > │ how to use my telephone." --- Bjarne Stroustrup > > > signature.asc > > 1KDownload --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] Announcing the new M5 SDK! http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---