예제 #1
0
 /**
  * Appends a frame to the current video.
  *
  * @param image the image to append
  * @return true if image successfully appended
  */
 protected boolean append(Image image) {
   BufferedImage bi;
   if (image instanceof BufferedImage) {
     bi = (BufferedImage) image;
   } else {
     bi = new BufferedImage(dim.width, dim.height, BufferedImage.TYPE_INT_RGB);
     Graphics2D g = bi.createGraphics();
     g.drawImage(image, 0, 0, null);
   }
   ByteArrayOutputStream out = new ByteArrayOutputStream();
   try {
     if (!editing) {
       videoMedia.beginEdits();
       editing = true;
     }
     ImageIO.write(bi, "png", out); // $NON-NLS-1$
     QTHandle handle = new QTHandle(out.toByteArray());
     DataRef dataRef = new DataRef(handle, kDataRefFileExtensionTag, "png"); // $NON-NLS-1$
     GraphicsImporter importer = new GraphicsImporter(dataRef);
     ImageDescription description = importer.getImageDescription();
     int duration = (int) (frameDuration * 0.6);
     videoMedia.addSample(
         handle,
         0, // data offset
         handle.getSize(),
         duration,
         description,
         1, // number of samples
         0); // key frame??
   } catch (Exception ex) {
     ex.printStackTrace();
     return false;
   }
   return true;
 }
예제 #2
0
  public void dispose() {
    if (readyForFrames) finish();

    try {
      QTSession.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
 public void stop() {
   try {
     if (qtc != null) {
       qtc.setMovie(null);
     }
     remove((Component) qtc);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
예제 #4
0
  public static void main(String args[]) {
    try {
      QTSession.open();
      GroupDrawing frame = new GroupDrawing("QT in Java");

      frame.pack();
      frame.show();
      frame.toFront();
    } catch (Exception e) {
      e.printStackTrace();
      QTSession.close();
    }
  }