這裏需要一點幫助:我走了,現在的想法......帆布畫:不能渲染動畫與運行時生成位圖圖像
這就是我需要做的:
- 渲染「base」圖像[由ARGB.8888字節數組創建]
- 用戶在屏幕上單擊2點;我需要對從一個點到另一個點的路徑周圍的像素區域執行像素操作... [我需要計算整個路徑上每個像素的squre塊像素]。
- 隨着代碼以動畫形式前進,顯示圖像的修改。
我能夠顯示整個路徑;我能夠計算&正確操縱像素..但我無法做的是顯示動畫,因爲我的代碼正在路徑上進行......使用當前實現,我可以在最後顯示整個計算路徑...
public void onDraw(Canvas canvas){
canvas.drawColor(Color.WHITE);
Paint p = new Paint();
canvas.drawBitmap(base,0,0,p);
traverse clickEvent1.x -> clickEvent2.x
traverse for clickEvent1.Y -> clickEvent2.Y
{
newBitMap = calculateNewBitMap(base)
// I nee to redraw Canvas with (newBitMap)
// canvas.drawBitMap(newBitMap);
//Doesn't work
//postInvalidate();
//invalidate()
//AnimationDrawable.addFrame(newBitMap)
// I am not calling start here
//but just wanted to let you know that I do call animation start to display the frames stored in it
// animation.start();
}
// obviously wouldn't work here As it is already out of the loop
//invalidate();
}
請注意:
- 的newBitMap圖像是在運行時產生的,它不會提供給我事先...
- 我試圖在環無效()作爲好 ;但它只會在整個循環遍歷之後繪製累積結果,而不是newBitMaps的中間狀態。
- 性能是至關重要的+我正在處理巨大的圖像大小..所以請記住,以及...如果我創建多個位圖臨時存儲JVM由於「OutofMemory」崩潰..
我嘗試以「AnimationDrawable」形式存儲新圖像;但THT不是解決問題以及....
AnimationDrawable animDrawable = new AnimationDrawable(); Drawable frame1 = new BitmapDrawable(newCaclBitMap); animDrawable.addFrame(frame1, 250);
感謝任何指針/建議..
感謝您將我指向CubeLiveWallpaper ...我解決了「LunarLander」和「cubeLiveWallpaper」實現方面的問題 – Pranav 2012-03-09 19:55:05