我想知道如何在JavaFX上拍摄节点的多个快照我有这个代码,但不幸的是它没有工作(或者给我想要的东西)
我认为问题出现在线程或循环中
public class FXMLDocumentController implements Initializable {
@FXML
private MediaView media_view;
@FXML
private ImageView image_view;
private Media me;
private MediaPlayer mp;
@Override
public void initialize(URL location, ResourceBundle resources)
{
// load a video and play it in the MediaView
String s = "/home/mustafa987/Videos/sampels/video10.mp4";
me = new Media(new File(s).toURI().toString());
mp = new MediaPlayer(me);
media_view.setMediaPlayer(mp);
mp.play();
mp.setRate(1);
}
//the record() method is invoked when i click a button
@FXML
void record(ActionEvent event) throws IOException
{
Runnable runnable=() -> {
while (true)
{
// snapshot -> buffered image -> image -> display in the ImageView
WritableImage img = media_view.snapshot(new SnapshotParameters(), null);
BufferedImage bufImg = SwingFXUtils.fromFXImage(img, null);
Image image=SwingFXUtils.toFXImage(bufImg, null);
image_view.setImage(image);
System.out.println(" - done - ");
try
{
Thread.sleep(1000); //take snapshot every 1 second
} catch (InterruptedException e)
{
System.out.println(e);
}
}
};
Thread thread=new Thread(runnable);
thread.start();
}
}
答案 0 :(得分:0)
由@Pagbo解决 来自here
的引用program test
use iso_fortran_env, r8 => real64
implicit none
integer, parameter :: ni = 130, nj = 130, nk = 130, nvar = 130
real(r8), allocatable :: u1(:,:,:,:), u2(:,:,:,:), w(:,:,:)
real(r8) :: sum, t0, t1
integer :: i,j,k,n
call cpu_time(t0)
allocate(u1(ni,nj,nk,nvar))
allocate(u2(ni,nj,nk,nvar))
allocate(w(ni,nj,nk))
call cpu_time(t1)
write(*,'("allocation time(s):",es15.5)') t1-t0
call cpu_time(t0)
call random_seed()
call random_number(u1)
call random_number(u2)
call random_number(w)
call cpu_time(t1)
write(*,'("random init time (s):",es15.5)') t1-t0
sum = 0.0_r8
call cpu_time(t0)
do n = 1, nvar
do k = 1, nk
do j = 1, nj
do i = 1, ni
sum = sum + u1(i,j,k,n)*u2(i,j,k,n)*w(i,j,k)
end do
end do
end do
end do
call cpu_time(t1)
write(*,'("Sum:",es15.5," time(s):",es15.5)') sum, t1-t0
end program