FileDocCategorySizeDatePackage
VFWAutoRGB.javaAPI DocJMF 2.1.1e3027Mon May 12 12:20:34 BST 2003None

VFWAutoRGB

public class VFWAutoRGB extends Object

Fields Summary
final Dimension
size160
final Dimension
size176
final Dimension
size320
final Dimension
size352
final Dimension
size640
final Dimension
size768
Dimension[]
sizes
VideoFormat[]
videoFormats
Constructors Summary
public VFWAutoRGB()


      
	MediaLocator locator;
	String name;
	
	prepareFormats();
	
        Vector devices = (Vector) CaptureDeviceManager.getDeviceList(null).clone();
        Enumeration enum = devices.elements();

        while (enum.hasMoreElements()) {
            CaptureDeviceInfo cdi = (CaptureDeviceInfo) enum.nextElement();
            name = cdi.getName();
            if (name.startsWith("vfw:"))
                CaptureDeviceManager.removeDevice(cdi);
        }

	System.out.println("\nWarning:\nThis program assumes that your " +
			   "capture devices support RGB capture\n");

        int nDevices = 0;
        for (int i = 0; i < 10; i++) {
            name = VFWCapture.capGetDriverDescriptionName(i);
            if (name != null && name.length() > 1) {
                System.out.println("Found device " + name);
                System.out.println("Registering for RGB capture");

		name = "vfw:" + name + ":" + i;
		locator = new MediaLocator("vfw://" + i);
		CaptureDeviceInfo cdi = new CaptureDeviceInfo(name,
							      locator,
							      videoFormats);
		CaptureDeviceManager.addDevice(cdi);
		
                nDevices++;
            }
        }
	try {
	    CaptureDeviceManager.commit();
	} catch (IOException ioe) {
	    System.err.println("Error committing---");
	    ioe.printStackTrace();
	}
    
Methods Summary
public static voidmain(java.lang.String[] args)

        VFWAutoRGB a = new VFWAutoRGB();
        System.exit(0);
    
protected voidprepareFormats()

	videoFormats = new VideoFormat[sizes.length * 2]; // For RGB16/24

	for (int i = 0; i < sizes.length; i++) {
	    Dimension size = sizes[i];
	    videoFormats[i] =
		new RGBFormat(size,
			      size.width * size.height * 3,
			      Format.byteArray,
			      Format.NOT_SPECIFIED,
			      24,
			      3, 2, 1,
			      3, size.width * 3,
			      RGBFormat.TRUE,
			      Format.NOT_SPECIFIED);
	    videoFormats[i+sizes.length] =
		new RGBFormat(size,
			      size.width * size.height * 2,
			      Format.byteArray,
			      Format.NOT_SPECIFIED,
			      16,
			      0x7C00, 0x03E0, 0x001F,
			      2, size.width * 2,
			      RGBFormat.TRUE,
			      RGBFormat.LITTLE_ENDIAN);
	}