Note that there are some explanatory texts on larger screens.

plurals
  1. POdisplay image after after on the panel with a time gap
    primarykey
    data
    text
    <pre><code>import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.image.*; import java.io.*; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; public class Video implements ActionListener { static int width=480; static int height=368; static JFrame frame = new JFrame(); static JButton button = new JButton("Submit"); static BufferedImage img = new BufferedImage((int) (width), (int) (height), BufferedImage.TYPE_INT_RGB); static BufferedImage img1[] = new BufferedImage[60]; static { for (int i = 0; i &lt; img1.length; i++) { img1[i] = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); } } public static void main(String[] args) { Video V1 = new Video(); String fileName = args[0]; try { File file = new File(fileName); InputStream is = new FileInputStream(file); long len = file.length(); byte[] bytes = new byte[(int)len]; int offset = 0; int numRead = 0; int ind =0; int[][] pixarray=new int[height+100][width+100]; int[][] red=new int[width*2][height*2]; int[][] green=new int[width*2][height*2]; int[][] blue=new int[width*2][height*2]; while (offset &lt; bytes.length &amp;&amp; (numRead=is.read(bytes, offset, bytes.length-offset)) &gt;= 0) { offset += numRead; } for(int frames=0;frames&lt;60;frames++) { ind=height*width*frames*3; for(int y = 0; y &lt; height; y++) { for(int x = 0; x &lt; width; x++) { byte a = 0; byte r = bytes[ind]; byte g = bytes[ind+height*width]; byte b = bytes[ind+height*width*2]; int pix = 0xff000000 | ((r &amp; 0xff) &lt;&lt; 16) | ((g &amp; 0xff) &lt;&lt; 8) | (b &amp; 0xff); pixarray[y][x]=pix; red[y][x] = (pix &gt;&gt;&gt; 16) &amp; 0xff; green[y][x] = (pix &gt;&gt;&gt; 8) &amp; 0xff; blue[y][x] = pix &amp; 0xff; img1[frames].setRGB(x,y,pix); ind++; } } } } catch (IOException e) { e.printStackTrace(); } JLabel label = new JLabel(new ImageIcon(img1[50])); frame.setLayout(new FlowLayout()); //frame.setSize(200,100); frame.setVisible(true); // Button button = new Button("Submit"); // frame.add(button); frame.getContentPane().add(label, BorderLayout.CENTER); frame.getContentPane().add(button, BorderLayout.CENTER); frame.pack(); frame.setVisible(true); button.addActionListener(V1); } public void actionPerformed(ActionEvent e) { System.out.println("1"); for(int i=0;i&lt;img1.length;i++) { try { Thread.sleep(500); } catch (InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } System.out.println(img1.length); } } } </code></pre> <p>Is my code. My img1 is an array of frames. in this instance my video has 60 frames.</p> <p>I wanna add each frame to my panel with a time gap. i am unable to do it because every time i add it to the panel in my <code>ActionEvent</code> its acting weird. help me out please.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload