1
Q
使用Gif圖像
A
回答
3
更多信息我打這樣的gif圖片...
public class GIFDemo extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new GIFView(this));
}
private static class GIFView extends View{
Movie movie,movie1;
InputStream is=null,is1=null;
long moviestart;
long moviestart1;
public GIFView(Context context) {
super(context);
is=context.getResources().openRawResource(R.drawable.cartoon);
is1=context.getResources().openRawResource(R.drawable.animated_gif);
movie=Movie.decodeStream(is);
movie1=Movie.decodeStream(is1);
//BitmapFactory.Options opts = new BitmapFactory.Options();
//opts.inJustDecodeBounds = true; // this will request the bm
// opts.inSampleSize = 10;
//movie=Movie.decodeFile("C:\\cartoon.gif");
}
@Override
protected void onDraw(Canvas canvas) {
canvas.drawColor(0xFFCCCCCC);
super.onDraw(canvas);
long now=android.os.SystemClock.uptimeMillis();
System.out.println("now="+now);
if (moviestart == 0) { // first time
moviestart = now;
}
if(moviestart1==0)
{
moviestart1=now;
}
System.out.println("\tmoviestart="+moviestart);
int relTime = (int)((now - moviestart) % movie.duration()) ;
int relTime1=(int)((now - moviestart1)% movie1.duration());
System.out.println("time="+relTime+"\treltime="+movie.duration());
movie.setTime(relTime);
movie1.setTime(relTime1);
movie.draw(canvas,10,10);
movie1.draw(canvas,10,100);
this.invalidate();
}
}
}
1
相關問題
- 1. 如何使用QSplashScreen使用gif圖像?
- 2. 爲GIF圖像
- 3. 圖像庫和gif圖像
- 4. 使用libMagick裁剪gif圖像
- 5. 使用Swift從圖像製作GIF(macOS)
- 6. .gif使用OpenGl的圖像顯示
- 7. 使用ffmpeg從jpeg圖像生成gif
- 8. 使用jquery將圖像更改爲gif
- 9. 如何在android中使用gif圖像?
- 10. php imagecopy不能使用gif圖像
- 11. Android使用圖像瀏覽和gif創建gif
- 12. 顯示GIF圖像
- 13. MBProgreeHud與gif圖像
- 14. 顯示GIF圖像
- 15. 比較GIF圖像像素
- 16. 將.png圖像轉換爲.gif圖像
- 17. 加載GIF圖像 - iPhone
- 18. gif圖像作爲背景
- 19. .gif圖像未複製
- 20. 設置GIF圖像toProgressBar
- 21. Xamarin.Forms中的GIF圖像
- 22. 在gif上顯示圖像
- 23. 調整大小。GIF圖像
- 24. 問題與GIF圖像
- 25. gif android中的圖像
- 26. 調整gif圖像大小
- 27. GIF圖像不顯示
- 28. GIF,然後圖像淡入
- 29. 按鈕中的GIF圖像
- 30. 使用PNG/GIF圖像作爲按鈕使用AS3