On 20/08/12 20:15, Nathan wrote: > I would like to do a copy on a bitmap from itself, ie, shift pixels in > a bitmap by copying from one rectangle to another rectangle. The src > and destination rectangles might overlap. This "snake eating its own > tail" trick did work in Windows and Windows Mobile. > > I see there is one issue logged about this on Android. > > http://code.google.com/p/android/issues/detail?id=3205 > > However, I don't know that it was ever supposed to work. I can't find > any documentation that suggests it should. > > Has anyone come up with an efficient solution for this? I know that > having yet another bitmap buffer the same size would work, but it is > something I want to avoid as it increases memory footprint (its not a > small bitmap). > > I'm not using native code, so a solution using smaller bitmaps and > drawing calls may not be very efficient.
What is the minimum Android version you're targetting? If you're not afraid of using native code - starting from API-8 (Android 2.2) you can relatively easily access Bitmap pixels from C code. http://mobilepearls.com/labs/native-android-api/#bitmap Calling AndroidBitmap_getInfo(..) would give you the dimensions, format and stride, AndroidBitmap_lockPixels(...) gives you the pointer to raw pixel data (it's just and array of pixels - bytes per pixel depends on bitmap format, the stride parameter tells you how many bytes to skip to get to next row). The rest is just moving/copying bytes... Note, that no bitmap copy is done this way, you can edit the Bitmap in place - it's thus really efficient. Another questions is - what are you actually trying to achieve? Perhaps there's another way around it? Best Regards, Przemek -- 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 android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en