/**
  * 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;
 }
Exemple #2
0
 /**
  * Gets a buffered image.
  *
  * @return the image
  */
 public BufferedImage getBufferedImage() {
   if (image == null && isAnImage) {
     Image im = getImage();
     if (im == null) {
       isAnImage = false;
     } else {
       image =
           new BufferedImage(im.getWidth(null), im.getHeight(null), BufferedImage.TYPE_INT_RGB);
       Graphics2D g2 = image.createGraphics();
       g2.drawImage(im, 0, 0, null);
     }
   }
   return image;
 }
Exemple #3
0
 /**
  * Draws this without refreshing steps.
  *
  * @param panel the drawing panel requesting the drawing
  * @param _g the graphics context on which to draw
  */
 public void drawMe(DrawingPanel panel, Graphics _g) {
   // position and show inspector if requested during loading
   if (inspectorX != Integer.MIN_VALUE
       && trackerPanel != null
       && trackerPanel.getTFrame() != null) {
     positionInspector();
     Runnable runner =
         new Runnable() {
           public void run() {
             showInspector = false;
             inspector.setVisible(true);
           }
         };
     if (showInspector) SwingUtilities.invokeLater(runner);
   }
   if (isVisible() && isTraceVisible()) {
     // draw trace only if fixed coords & (non-worldview or no ref frame)
     TrackerPanel tPanel = (TrackerPanel) panel;
     ImageCoordSystem coords = tPanel.getCoords(); // get active coords
     boolean isRefFrame = coords instanceof ReferenceFrame;
     if (isRefFrame) {
       coords = ((ReferenceFrame) coords).getCoords();
     }
     boolean fixed = coords.isFixedAngle() && coords.isFixedOrigin() && coords.isFixedScale();
     if (fixed && (!(tPanel instanceof WorldTView) || !isRefFrame)) {
       trace.reset();
       for (int i = 0; i < traceX.length; i++) {
         if (Double.isNaN(traceX[i])) continue;
         tracePt.setLocation(traceX[i], traceY[i]);
         java.awt.Point p = tracePt.getScreenPosition(tPanel);
         if (trace.getCurrentPoint() == null) trace.moveTo((float) p.getX(), (float) p.getY());
         else trace.lineTo((float) p.getX(), (float) p.getY());
       }
       Graphics2D g2 = (Graphics2D) _g;
       Color color = g2.getColor();
       Stroke stroke = g2.getStroke();
       g2.setColor(getFootprint().getColor());
       g2.setStroke(traceStroke);
       g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
       g2.draw(trace);
       // restore original color and stroke
       g2.setColor(color);
       g2.setStroke(stroke);
     }
   }
   super.draw(panel, _g);
 }