2010-11-16 31 views

回答

0

你应该看看位图定义

与[这] [1]你应该能够做到这一点

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)

编辑: 也许这个更简单

公共静态位图createBitmap(位图源,诠释的x,INT Y,INT宽度,高度INT)

应该是这个样子(4分,你就必须制定出你的循环,使其在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); 

我没有时间去创造我的电脑上测试代码把这个应该让你开始。

也可以尝试这个

try { 
       FileOutputStream out = new FileOutputStream("/sdcard/image"+num+".png"); 
       mBitmap.compress(Bitmap.CompressFormat.PNG, 90, out); 
      } catch (Exception e) { 
       e.printStackTrace(); 
      } 

它会在你的SD卡,这将有助于你看是否正确生成位图上创建位图的副本。

+0

对不起,关于答案的格式,但是当我编辑它时,它很好... – 2010-11-16 07:50:25

+0

我无法通过使用上述代码找到任何解决方案。你能帮我么。我如何才能实现它。 – 2010-11-16 09:13:46

+0

谢谢我正在尝试这个。 – 2010-11-16 10:26:03

相关问题