FileDocCategorySizeDatePackage
Java2DRenderer.javaAPI DocFobs4JMF API 0.4.16208Wed Jan 10 11:49:24 GMT 2007com.omnividea.media.renderer.video

Java2DRenderer

public class Java2DRenderer extends JPanel implements VideoRenderer, FrameGrabbingControl
FOBS Java CrossPlatform JMF PlugIn Copyright (c) 2004 Omnividea Multimedia S.L This file is part of FOBS. FOBS is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. FOBS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with FOBS; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Fields Summary
private BufferStrategy
strategy
private RGBFormat
vf
private Image
lastImage
Constructors Summary
public Java2DRenderer()

        //panel.setIgnoreRepaint(true);
	    setIgnoreRepaint(true);
    
Methods Summary
private java.awt.image.BufferedImagebufferToImage(javax.media.Buffer buffer)

       RGBFormat format = (RGBFormat) buffer.getFormat();
       int rMask, gMask, bMask;
       Object data = buffer.getData();
       DirectColorModel dcm;

       rMask = format.getRedMask();
       gMask = format.getGreenMask();
       bMask = format.getBlueMask();
       int [] masks = new int[3];
       masks[0] = rMask;
       masks[1] = gMask;
       masks[2] = bMask;

       DataBuffer db = new DataBufferInt((int[])data,
                         format.getLineStride() *
                         format.getSize().height);

       SampleModel sm = new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT,
                                 format.getLineStride(),
                                 format.getSize().height,
                                 masks);
       WritableRaster wr = Raster.createWritableRaster(sm, db, new Point(0, 0));

       dcm = new DirectColorModel(24, rMask, gMask, bMask);
       return new BufferedImage(dcm, wr, true, null);
   
public voidclose()

        lastImage = null;
    
public java.awt.ComponentgetComponent()

        return this;
    
public java.lang.ObjectgetControl(java.lang.String arg)

 
    Object rc = null; 
    if(arg.equals("javax.media.control.FrameGrabbingControl")) rc = this; 
    return rc; 
  
public java.awt.ComponentgetControlComponent()

 
    return null; 
  
public java.lang.Object[]getControls()

 
    Object[] obj = { this }; 
    return obj; 
  
public java.lang.StringgetName()

        return "Fobs Java2DRenderer";
    
public javax.media.Format[]getSupportedInputFormats()

return new Format[] {new RGBFormat() };
public javax.media.BuffergrabFrame()

 
	Buffer buf = null;
	if(lastImage != null) ImageToBuffer.createBuffer(lastImage,(float)0); 
	return buf; 
  
public voidopen()

        
    
protected voidpaintComponent(java.awt.Graphics g)

 
        if(lastImage != null) g.drawImage(lastImage, 0, 0, this.getWidth(),this.getHeight(), null); 
    
public intprocess(javax.media.Buffer buffer)

		Graphics2D g2d = (Graphics2D) this.getGraphics();					    
				    
		if(g2d != null) {
			if(lastImage == null) lastImage = bufferToImage(buffer);
			g2d.drawImage(lastImage, 0, 0, this.getWidth(),this.getHeight(), null);
			//g2d.dispose();
		}
		
		return BUFFER_PROCESSED_OK;
    
public voidreset()

        lastImage = null;
    
public booleansetComponent(java.awt.Component arg0)

        return false;
    
public javax.media.FormatsetInputFormat(javax.media.Format format)

        System.out.println("Fobs Java2DRenderer: setInputFormat");
        FobsConfiguration.videoFrameFormat=FobsConfiguration.RGBA;

        vf = (RGBFormat) format;
	int formatWidth = (int) vf.getSize().getWidth();
	int formatHeight = (int) vf.getSize().getHeight();
	this.setPreferredSize(new Dimension(formatWidth,formatHeight));
	return format;
    
voidsetValue(java.lang.Object aValue, boolean isSelected)

        
        
        System.out.println(aValue.getClass().getName());
    
public voidstart()

        System.out.println("Fobs Java2DRenderer: start");
    
public voidstop()

        System.out.println("Fobs Java2DRenderer: stop");