0
我只是想將一個大的圖像分解成一些相等的部分,如4,6或8。 我們可以做到嗎? 實際上,我想將圖像的每個部分作爲獨立圖像存儲在我的 可繪製文件夾中以供將來使用。如何在Android上將一個大圖像分成8個相等部分
任何人都可以幫助我嗎?
在此先感謝 蘇尼特
我只是想將一個大的圖像分解成一些相等的部分,如4,6或8。 我們可以做到嗎? 實際上,我想將圖像的每個部分作爲獨立圖像存儲在我的 可繪製文件夾中以供將來使用。如何在Android上將一個大圖像分成8個相等部分
任何人都可以幫助我嗎?
在此先感謝 蘇尼特
你應該看看位圖定義
與[這] [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卡,這將有助於你看是否正確生成位圖上創建位圖的副本。
對不起,關於答案的格式,但是當我編輯它時,它很好... – 2010-11-16 07:50:25
我無法通過使用上述代碼找到任何解決方案。你能幫我麼。我如何才能實現它。 – 2010-11-16 09:13:46
謝謝我正在嘗試這個。 – 2010-11-16 10:26:03