Package javax.media.format

Examples of javax.media.format.RGBFormat


    c.setPlugInName("abc");
    assertEquals(c.getName(), "abc");
   

    c.setDefaultOutputFormats(new VideoFormat[]{
        new RGBFormat(new java.awt.Dimension(320, 200), 64000, Format.intArray, 1.3414634f, 32, 0xff, 0xff00, 0xff0000, 1, 320, 0, -1)
    });
    {
      VideoFormat f = new VideoFormat("xyz", new Dimension(1, 2), 1000, byte[].class, 2.f);
      //assertEquals(c.checkFormat(new VideoFormat("xyz", new Dimension(1, 2), 1000, byte[].class, 2.f)), true);
      VideoFormat[] fs = new VideoFormat[] {f};
View Full Code Here


   
    if (OSUtils.isMacOSX() && !ClasspathChecker.checkManagerImplementation()) // TODO: why do we get two of the same on the mac using JMF?
    {
      supportedInputFormats = new Format[] {
          //RGB, 32-bit, Masks=16711680:65280:255, LineStride=-1, class [I
          new RGBFormat(null, -1, Format.intArray, -1.0f, 32, 0xff0000, 0xff00, 0xff, 1, -1, 0, -1),
         
          // TODO: why do we get two of the same on the mac using JMF?
          new RGBFormat(null, -1, Format.intArray, -1.0f, 32, 0xff0000, 0xff00, 0xff, 1, -1, 0, -1),
       
        };
    }
    else
    {
      supportedInputFormats = new Format[] {
          //RGB, 32-bit, Masks=16711680:65280:255, LineStride=-1, class [I
          new RGBFormat(null, -1, Format.intArray, -1.0f, 32, 0xff0000, 0xff00, 0xff, 1, -1, 0, -1),
         
          //RGB, 32-bit, Masks=255:65280:16711680, LineStride=-1, class [I
          new RGBFormat(null, -1, Format.intArray, -1.0f, 32, 0xff, 0xff00, 0xff0000, 1, -1, 0, -1)
       
        };
    }
   
    final Format[] formats = r.getSupportedInputFormats();
View Full Code Here

      com.lti.civil.CaptureDeviceInfo civilInfo = (com.lti.civil.CaptureDeviceInfo) list.get(i);
     
      {
       
        //String name, MediaLocator locator, Format[] formats
        CaptureDeviceInfo jmfInfo = new CaptureDeviceInfo(civilInfo.getDescription(), new MediaLocator("civil:" + civilInfo.getDeviceID()), new Format[] {new RGBFormat()});
        CaptureDeviceManager.addDevice(jmfInfo);
      }
     
    }
View Full Code Here

        assertEquals(fRelax.getSize(), null);
                         
      }
     
      if (f1 instanceof RGBFormat)
      {  final RGBFormat vf1 = (RGBFormat) f1;
        if (vf1.getSize() != null)
          assertFalse(vf1.getSize() == ((RGBFormat) vf1.clone()).getSize());
       
        final RGBFormat fRelax = (RGBFormat) f1.relax();
        assertEquals(fRelax.getEncoding(), vf1.getEncoding());
        assertEquals(fRelax.getDataType(), vf1.getDataType());
        assertEquals(fRelax.getFrameRate(), -1.f);
        assertEquals(fRelax.getMaxDataLength(), -1);
        assertEquals(fRelax.getSize(), null);
        assertEquals(fRelax.getLineStride(), -1);
        assertEquals(fRelax.getPixelStride(), -1);
                         
      }
     
      if (f1.getClass() == Format.class)
      {
View Full Code Here

        int bMask = 0x000000FF;

        supportedFormats = new Format[] {

                // RGB format
                new RGBFormat(
                        null,                 // size
                        Format.NOT_SPECIFIED, // maxDataLength
                        Format.intArray,      // buffer type
                        Format.NOT_SPECIFIED, // frame rate
                        32,                   // bitsPerPixel
                        rMask, gMask, bMask,  // component masks
                        1,                    // pixel stride
                        Format.NOT_SPECIFIED, // line stride
                        Format.FALSE,         // flipped
                        Format.NOT_SPECIFIED  // endian
                ),

                // BGR format
                new RGBFormat(
                        null,                 // size
                        Format.NOT_SPECIFIED, // maxDataLength
                        Format.intArray,      // buffer type
                        Format.NOT_SPECIFIED, // frame rate
                        32,                   // bitsPerPixel
View Full Code Here

  public void testBufferToImage()
  {
    {
      try
      {
        final VideoFormat format = new RGBFormat();
        final BufferToImage b2i = new BufferToImage(format);
        assertTrue(false);
      }
      catch (NullPointerException e)
      {
      }
    }
   
    {
      final RGBFormat format = new RGBFormat(new Dimension(16, 16), 16 * 16, Format.intArray, 1.3414634f, 32, 0xff, 0xff00, 0xff0000, 1, 16, 0, -1);
     
      assertEquals(format.getLineStride(), 16)
      assertEquals(format.getPixelStride(), 1);
      assertEquals(format.getEndian(), -1);
      assertEquals(format.getFlipped(), 0);
   
     
      final BufferToImage b2i = new BufferToImage(format);
     
      final Buffer buffer = new Buffer();
      buffer.setFormat(format);
      //System.out.println(format.getMaxDataLength());
      final int[] ba = new int[format.getMaxDataLength()];
      ba[0] = 2;
      buffer.setData(ba);
     
      final BufferedImage i = (BufferedImage) b2i.createImage(buffer);
      assertTrue(i != null);
      assertEquals(i.getWidth(), format.getSize().width);
      assertEquals(i.getHeight(), format.getSize().height);
      assertEquals(i.getColorModel().getColorSpace().getType(), ColorSpace.TYPE_RGB);
      assertEquals(i.getType(), BufferedImage.TYPE_INT_BGR);
      // TODO: check other attributes, and pixels
      int[] pix = i.getRaster().getPixel(0, 0, (int[]) null);
      assertEquals(pix[0], 2);
View Full Code Here

  public void testGen()
  {
    if (true)
      return// disabled, since currently generated code is already pasted into this class.

    gen(new RGBFormat(new Dimension(4, 4), 4 * 4, Format.intArray, 1.3414634f, 32, 0xff, 0xff00, 0xff0000, 1, 4, 0, -1));
    gen(new RGBFormat(new Dimension(4, 4), 4 * 4, Format.intArray, 1.3414634f, 32, 0xff0000, 0xff00, 0xff, 1, 4, 0, -1));
   
    // TODO: flipped, others
   

  }
View Full Code Here

  }

  public void testBig()
  {
    {
      final RGBFormat f = new RGBFormat(new java.awt.Dimension(4, 4), 16, Format.intArray, 1.3414634f, 32, 0xff, 0xff00, 0xff0000, 1, 4, 0, -1);
      assertEquals(f.getLineStride(), 4);
      assertEquals(f.getPixelStride(), 1);
      assertEquals(f.getEndian(), -1);
      assertEquals(f.getFlipped(), 0);
      final BufferToImage b2i = new BufferToImage(f);
      final Buffer buffer = new Buffer();
      buffer.setFormat(f);
      buffer.setData(new int[] {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15});
      final BufferedImage i = (BufferedImage) b2i.createImage(buffer);
      assertTrue(i != null);
      assertEquals(i.getWidth(), f.getSize().width);
      assertEquals(i.getHeight(), f.getSize().height);
      assertEquals(i.getColorModel().getColorSpace().getType(), ColorSpace.TYPE_RGB);
      assertEquals(i.getType(), BufferedImage.TYPE_INT_BGR);
      final int[][] target = new int[][] {new int[] {0,0,0},new int[] {1,0,0},new int[] {2,0,0},new int[] {3,0,0},new int[] {4,0,0},new int[] {5,0,0},new int[] {6,0,0},new int[] {7,0,0},new int[] {8,0,0},new int[] {9,0,0},new int[] {10,0,0},new int[] {11,0,0},new int[] {12,0,0},new int[] {13,0,0},new int[] {14,0,0},new int[] {15,0,0},};
      for (int y = 0; y < f.getSize().height; ++y)
      {
        for (int x = 0; x < f.getSize().width; ++x)
        {
          final int[] pix = i.getRaster().getPixel(x, y, (int[]) null);
          assertEquals(pix[0], target[x + y * f.getSize().width][0]);
          assertEquals(pix[1], target[x + y * f.getSize().width][1]);
          assertEquals(pix[2], target[x + y * f.getSize().width][2]);
        }
      }
    }
    {
      final RGBFormat f = new RGBFormat(new java.awt.Dimension(4, 4), 16, Format.intArray, 1.3414634f, 32, 0xff0000, 0xff00, 0xff, 1, 4, 0, -1);
      assertEquals(f.getLineStride(), 4);
      assertEquals(f.getPixelStride(), 1);
      assertEquals(f.getEndian(), -1);
      assertEquals(f.getFlipped(), 0);
      final BufferToImage b2i = new BufferToImage(f);
      final Buffer buffer = new Buffer();
      buffer.setFormat(f);
      buffer.setData(new int[] {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15});
      final BufferedImage i = (BufferedImage) b2i.createImage(buffer);
      assertTrue(i != null);
      assertEquals(i.getWidth(), f.getSize().width);
      assertEquals(i.getHeight(), f.getSize().height);
      assertEquals(i.getColorModel().getColorSpace().getType(), ColorSpace.TYPE_RGB);
      assertEquals(i.getType(), BufferedImage.TYPE_INT_RGB);
      final int[][] target = new int[][] {new int[] {0,0,0},new int[] {0,0,1},new int[] {0,0,2},new int[] {0,0,3},new int[] {0,0,4},new int[] {0,0,5},new int[] {0,0,6},new int[] {0,0,7},new int[] {0,0,8},new int[] {0,0,9},new int[] {0,0,10},new int[] {0,0,11},new int[] {0,0,12},new int[] {0,0,13},new int[] {0,0,14},new int[] {0,0,15},};
      for (int y = 0; y < f.getSize().height; ++y)
      {
        for (int x = 0; x < f.getSize().width; ++x)
        {
          final int[] pix = i.getRaster().getPixel(x, y, (int[]) null);
          assertEquals(pix[0], target[x + y * f.getSize().width][0]);
          assertEquals(pix[1], target[x + y * f.getSize().width][1]);
          assertEquals(pix[2], target[x + y * f.getSize().width][2]);
        }
      }
    }
  }
 
View Full Code Here

  }

  public Format[] getSupportedOutputFormats(Format input)
  {
    trace("getSupportedOutputFormats " + input);
    return new Format[] {new RGBFormat()};
  }
View Full Code Here

  public void XXXtestBufferToImage()
  {
    {
      try
      {
        final VideoFormat format = new RGBFormat();
        final BufferToImage b2i = new BufferToImage(format);
        assertTrue(false);
      }
      catch (NullPointerException e)
      {
      }
    }
   
    {
      // 24bit rgb: r,g,b:
      final RGBFormat format = new RGBFormat(new Dimension(16, 16), 16 * 16 * 3, Format.byteArray, -1.f, 24, 1, 2, 3);
      assertEquals(format.getLineStride(), 16 * 3)
      assertEquals(format.getPixelStride(), 3);
      assertEquals(format.getEndian(), -1);
      assertEquals(format.getFlipped(), 0);
   
     
      final BufferToImage b2i = new BufferToImage(format);
     
      final Buffer buffer = new Buffer();
      buffer.setFormat(format);
      //System.out.println(format.getMaxDataLength());
      final byte[] ba = new byte[format.getMaxDataLength()];
      ba[0] = 2;
      buffer.setData(ba);
     
      final BufferedImage i = (BufferedImage) b2i.createImage(buffer);
      assertTrue(i != null);
      assertEquals(i.getWidth(), format.getSize().width);
      assertEquals(i.getHeight(), format.getSize().height);
      assertEquals(i.getColorModel().getColorSpace().getType(), ColorSpace.TYPE_RGB);
      assertEquals(i.getType(), BufferedImage.TYPE_INT_RGB);
      // TODO: check other attributes, and pixels
      int[] pix = i.getRaster().getPixel(0, 0, (int[]) null);
      assertEquals(pix[0], 2);
      assertEquals(pix[1], 0);
      assertEquals(pix[2], 0);
     
     
     
      //System.out.println(i.getClass());
    }
   
    {
      // 24bit rgb: r,g,b:
      final RGBFormat format = new RGBFormat(new Dimension(4, 4), 4 * 4 * 3, Format.byteArray, -1.f, 24, 1, 2, 3);
      assertEquals(format.getLineStride(), 4 * 3)
      assertEquals(format.getPixelStride(), 3);
      assertEquals(format.getEndian(), -1);
      assertEquals(format.getFlipped(), 0);
     
     
      final BufferToImage b2i = new BufferToImage(format);
     
      final Buffer buffer = new Buffer();
      buffer.setFormat(format);
      //System.out.println(format.getMaxDataLength());
      final byte[] ba = new byte[format.getMaxDataLength()];
      ba[0] = 2;
      buffer.setData(ba);
     
      final BufferedImage i = (BufferedImage) b2i.createImage(buffer);
      assertTrue(i != null);
      assertEquals(i.getWidth(), format.getSize().width);
      assertEquals(i.getHeight(), format.getSize().height);
      assertEquals(i.getColorModel().getColorSpace().getType(), ColorSpace.TYPE_RGB);
      assertEquals(i.getType(), BufferedImage.TYPE_INT_RGB);
      // TODO: check other attributes, and pixels
      int[] pix = i.getRaster().getPixel(0, 0, (int[]) null);
      assertEquals(pix[0], 2);
View Full Code Here

TOP

Related Classes of javax.media.format.RGBFormat

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.