android - How to swap regions in bitmap -
ex.:
i have bitmap size 500x500. , on bitmap have coordinates 2 regions. 1 region @ x=10, y=10, size 10x10 second region @ x=400, y=400, size 10x10
what best way swap 2 regions in bitmap.
you can trough canvas.
something like:
bitmap swapped = bitmap.createbitmap(origin.getwidth(), origin.getheight(), origin.getconfig()); canvas drawer = new canvas(swapped); drawer.drawbitmap(origin, new rect(0,0,100,100), new rect(100,100,100,100), paint); drawer.drawbitmap(origin, new rect(100,100,100,100), new rect(0,0,100,100), paint);
at point 'swapped' bitmap have origin pieces drawed in different regions.
for more see canvas documentation:
http://developer.android.com/reference/android/graphics/canvas.html#drawbitmap(android.graphics.bitmap, android.graphics.matrix, android.graphics.paint)
Comments
Post a Comment