how to break a large image into 8 equal parts in android -
want break large image equal parts 4, 6 or 8. can it? want store every parts of image separate image in drawable folder future use.
can 1 me?
thanks in advance sunit
you should bitmap definition
with [this][1] should able
public static bitmap createbitmap (bitmap source, int x, int y, int width, int height, matrix m, boolean filter)
[1]: http://developer.android.com/reference/android/graphics/bitmap.html#createbitmap(android.graphics.bitmap, int, int, int, int, android.graphics.matrix, boolean)
edit: maybe 1 simpler
public static bitmap createbitmap (bitmap source, int x, int y, int width, int height)
should (divided in 4, you'll have work out loops make work on 4,6,8 ...
bitmap source = ...; int halfwidth = source.getwidth()/2; int halfheight = source.getheight()/2; bitmap topleft, topright, bottomleft, bottomright; topleft = createbitmap(source,0,0,halfwidth ,halfheight); topright= createbitmap(source,halfwidth ,0,halfwidth ,halfheight); bottomleft= createbitmap(source ,0,halfheight,halfwidth ,halfheight); bottomright = createbitmap(source ,halfwidth ,halfheight,halfwidth ,halfheight);
i don't have time create test code on computer put should started.
also try
try { fileoutputstream out = new fileoutputstream("/sdcard/image"+num+".png"); mbitmap.compress(bitmap.compressformat.png, 90, out); } catch (exception e) { e.printstacktrace(); }
it create copy of bitmap on sdcard see if bitmap generated correctly.
Comments
Post a Comment