2010-11-16 32 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

相關問題