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. 使用ffmpeg从jpeg图像生成gif
- 5. 使用jquery将图像更改为gif
- 6. 如何在android中使用gif图像?
- 7. 使用Swift从图像制作GIF(macOS)
- 8. .gif使用OpenGl的图像显示
- 9. MBProgreeHud与gif图像
- 10. 显示GIF图像
- 11. 比较GIF图像像素
- 12. 将.png图像转换为.gif图像
- 13. Xamarin.Forms中的GIF图像
- 14. 问题与GIF图像
- 15. gif android中的图像
- 16. 设置GIF图像toProgressBar
- 17. GIF,然后图像淡入
- 18. gif图像作为背景
- 19. 调整大小。GIF图像
- 20. 在gif上显示图像
- 21. 使用PNG/GIF图像作为按钮使用AS3
- 22. 使用UIWebView使用tiff和gif格式图像的问题
- 23. 将gif图像转换为像素然后回到gif
- 24. 如何在Android中使用两个位图制作gif图像
- 25. 在表面视图中使用Gif图像?
- 26. 使用PHP imagecreatefromgif()修改760x1像素gif图像的右侧150像素
- 27. 使用pygame将多帧/移动的.gif图像加载到python
- 28. 如何使用WindowsPhotoGallery在Java中显示gif图像?
- 29. 无法在使用Qt的MIPSel设备中显示gif图像
- 30. 如何使用XAML从UWP中的URL显示GIF图像?