动画和gif文件制作

来自Shiyin's note
159.226.169.140讨论2012年4月7日 (六) 13:36的版本
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳到导航 跳到搜索
  • 生成mpeg的xinteranimate命令中,需要预先定义视频到帧数
  • 在生成gif文件的 write_gif命令,只需要定义 /multiple,可以一直写入
gif是8位的颜色,而device的默认是24位颜色。
在设置device,decomposed=0 (8位伪彩色)的时候,屏幕显示颜色完全正确,但在生成的gif文件中的颜色表似乎是按照真彩色来的。
设置device,decomposed=1,屏幕显示不对,但gif文件中正确。
pro animate
xh=800 & yh=600 & n=100
device,retain=2
;
x=findgen(628)*0.01
xinteranimate,20,set=[xh,yh,n],/mpeg_open,mpeg_quality=100,$
mpeg_filename='sinx.mpg',title='Example'
;
window,0,xsize=xh,ysize=yh
for i=0,n-1 do begin
  plot,x,sin(x-i*0.05),xstyle=1,ystyle=1,title='sin(x) is moving...'
  WRITE_GIF, 'test.gif', TVRD(),/multiple
  xinteranimate,frame=i,window=0
endfor
xinteranimate,/mpeg_close,/close
end