0
我正在處理一組分層圖像(認爲堆疊),我需要將它們合併爲一個元素。在Android中,爲什麼我的組合位圖是空白的?
我立足我解掉Combine multiple bitmap into one
//send a map to the method that has my stored image locations in order
private Bitmap combineImageIntoOne(NavigableMap<Integer, String> layerImages) {
//size of my bitmaps
int w = 400, h = 400;
//bitmap placeholder
Bitmap productIndex = null;
//flattened layers
Bitmap temp = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
//canvas to write layers to
Canvas canvas = new Canvas(temp);
int top = 0;
for (Map.Entry<Integer, String> e : layerImages.entrySet()) {
//create the layer bitmap
productIndex = decodeSampledBitmapFromResource(getResources(), e.getValue(), 400, 400);
//add layer to canvas
canvas.drawBitmap(productIndex, 0f, top, null);
}
//convert temp to a BitmapDrawable
Drawable d = new BitmapDrawable(getResources(),temp);
//set my image view to have the flattened image
carBase.setImageDrawable(d);
return temp;
}
的decodeSampledBitmapFromResource
來自有關加載大位圖在Android文檔:Loading Large Bitmaps Efficiently您可以查看有關該文檔的代碼,看看我「米做什麼,我沒編輯Android代碼太多了
我一直在使用Android代碼,很好地將圖層添加到FrameLayout中,但是當圖層數量開始變得很大時,結果內存不足了。用於節省內存空間。
任何想法爲什麼最終的位圖沒有任何內容?
感謝這個,我會進行審覈和鏈接,看看我是否可以把它爲我工作。我注意到它說「兩個圖像」我有一個數組,可能有......可能...... 10個或更多。我可能能夠修改這個方法的循環,並得到我想要的結果。謝謝。 – dcp3450