当前位置: 首页>>代码示例>>Java>>正文


Java Format.byteArray方法代码示例

本文整理汇总了Java中javax.media.Format.byteArray方法的典型用法代码示例。如果您正苦于以下问题:Java Format.byteArray方法的具体用法?Java Format.byteArray怎么用?Java Format.byteArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.media.Format的用法示例。


在下文中一共展示了Format.byteArray方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: PowerMeter

import javax.media.Format; //导入方法依赖的package包/类
public PowerMeter(int nPowersPerSec) {
this.nPowersPerSec = nPowersPerSec;
timeStamps = new long[nPowersPerSec * NUM_SECONDS];
powers = new float[nPowersPerSec * NUM_SECONDS];
inputFormats = new Format[] {new AudioFormat(AudioFormat.LINEAR,
					     Format.NOT_SPECIFIED,
					     16,
					     Format.NOT_SPECIFIED,
					     Format.NOT_SPECIFIED,
					     Format.NOT_SPECIFIED,
					     Format.NOT_SPECIFIED,
					     Format.NOT_SPECIFIED,
					     Format.byteArray)};

outputFormats = new Format[] {new AudioFormat(AudioFormat.LINEAR,
					      Format.NOT_SPECIFIED,
					      16,
					      Format.NOT_SPECIFIED,
					      Format.NOT_SPECIFIED,
					      Format.NOT_SPECIFIED,
					      Format.NOT_SPECIFIED,
					      Format.NOT_SPECIFIED,
					      Format.byteArray)};
   }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:25,代码来源:PowerMeter.java

示例2: nextDataType

import javax.media.Format; //导入方法依赖的package包/类
public Class<?> nextDataType() throws ParseException
{
    String s = nextString();
    if (s == null)
        return null;

    if (s.equals(NOT_SPECIFIED))
        return null;

    s = s.toUpperCase();

    if (s.equals(BYTE_ARRAY))
        return Format.byteArray;
    else if (s.equals(SHORT_ARRAY))
        return Format.shortArray;
    else if (s.equals(INT_ARRAY))
        return Format.intArray;
    else
        throw new ParseException("Expected one of [" + BYTE_ARRAY + ","
                + SHORT_ARRAY + "," + INT_ARRAY + "]: " + s, -1);

}
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:23,代码来源:FormatArgUtils.java

示例3: dataTypeToStr

import javax.media.Format; //导入方法依赖的package包/类
private static final String dataTypeToStr(Class<?> clazz)
{
    if (clazz == null)
    {
        return NOT_SPECIFIED;
    }
    if (clazz == Format.byteArray)
    {
        return BYTE_ARRAY;
    }
    if (clazz == Format.shortArray)
    {
        return SHORT_ARRAY;
    }
    if (clazz == Format.intArray)
    {
        return INT_ARRAY;
    }

    throw new IllegalArgumentException("" + clazz);

}
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:23,代码来源:FormatArgUtils.java

示例4: readHeader

import javax.media.Format; //导入方法依赖的package包/类
private void /* for now void */ readHeader()
    throws IOException, BadHeaderException {

    minLocation = getLocation(stream); // Should be zero

    long contentLength = stream.getContentLength();
    if ( contentLength != SourceStream.LENGTH_UNKNOWN ) {
        double durationSeconds = contentLength / bytesPerSecond;


        duration = new Time(durationSeconds);
        maxLocation = contentLength;

    } else {
        maxLocation = Long.MAX_VALUE;
    }

    boolean signed = true;
    boolean bigEndian = false;
    format = new AudioFormat(AudioFormat.GSM,
                             8000,  // sampleRate,
                             16,    // sampleSizeInBits,
                             1,     // channels,
                             bigEndian ? AudioFormat.BIG_ENDIAN : 
                            AudioFormat.LITTLE_ENDIAN,
                             signed ? AudioFormat.SIGNED : 
                            AudioFormat.UNSIGNED,
                             (blockSize * 8), // frameSizeInBits
                             Format.NOT_SPECIFIED,  
                             Format.byteArray);
}
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:32,代码来源:GsmParser.java

示例5: read

import javax.media.Format; //导入方法依赖的package包/类
public void read(Buffer buffer) throws IOException {
synchronized (this) {
    Object outdata = buffer.getData();
    if (outdata == null || !(outdata.getClass() == Format.byteArray) ||
	((byte[])outdata).length < maxDataLength) {
	outdata = new byte[maxDataLength];
	buffer.setData(outdata);
    }
    if (videoData) {
	buffer.setFormat( rgbFormat );
	buffer.setTimeStamp( (long) (seqNo * (1000 / frameRate) * 1000000) );
	int lineNo = (seqNo * 2) % size.height;
	int chunkStart = lineNo * size.width * 3;
	System.arraycopy(data, chunkStart,
			 outdata, 0,
			 maxDataLength - (chunkStart));
	if (chunkStart != 0) {
	    System.arraycopy(data, 0,
			     outdata, maxDataLength - chunkStart,
			     chunkStart);
	}
    } else {
	buffer.setFormat( audioFormat );
	buffer.setTimeStamp( 1000000000 / 8 );
	for (int i = 0; i < 1000; i++) {
	    ((byte[])outdata)[i] = (byte) (Math.sin(i / freq) * 32);
	    freq = (freq + 0.01);
	    if (freq > 10.0)
		freq = 2.0;
	}
    }
    buffer.setSequenceNumber( seqNo );
    buffer.setLength(maxDataLength);
    buffer.setFlags(0);
    buffer.setHeader( null );
    seqNo++;
}
   }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:39,代码来源:LiveStream.java

示例6: ImageSourceStream

import javax.media.Format; //导入方法依赖的package包/类
public ImageSourceStream(int width, int height, int frameRate, Vector images) {
    this.width = width;
    this.height = height;
    this.images = images;

    format = new VideoFormat(VideoFormat.JPEG,
			new Dimension(width, height),
			Format.NOT_SPECIFIED,
			Format.byteArray,
			(float)frameRate);
}
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:12,代码来源:JpegImagesToMovie.java

示例7: RotationEffect

import javax.media.Format; //导入方法依赖的package包/类
public RotationEffect(int num) {
    if ( num <= 0 )
        this.num = 20;
    else
        this.num = num;
    this.angle = 2.0*3.1415926/this.num;
    buildTable();

    inputFormats = new Format[] {
        new RGBFormat(null,
                      Format.NOT_SPECIFIED,
                      Format.byteArray,
                      Format.NOT_SPECIFIED,
                      24,
                      3, 2, 1,
                      3, Format.NOT_SPECIFIED,
                      Format.TRUE,
                      Format.NOT_SPECIFIED)
    };

    outputFormats = new Format[] {
        new RGBFormat(null,
                      Format.NOT_SPECIFIED,
                      Format.byteArray,
                      Format.NOT_SPECIFIED,
                      24,
                      3, 2, 1,
                      3, Format.NOT_SPECIFIED,
                      Format.TRUE,
                      Format.NOT_SPECIFIED)
    };

}
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:34,代码来源:RotationEffect.java

示例8: convertCodecPixelFormat

import javax.media.Format; //导入方法依赖的package包/类
public static VideoFormat convertCodecPixelFormat(QTSnapper qtSnapper)
  {
  	// resulting format based on what QTSnapper will return.  Depends on a bit of internal 
  	// knowledge of how QTSnapper and ImageToBuffer work.
  	
  	// TODO: we are ignoring any cropping here.
  	
  	//final Dimension size = new Dimension(128, 128);
final Dimension size = new Dimension(qtSnapper.getImageWidth(), qtSnapper.getImageHeight());
final int maxDataLength;
final Class dataType;
final int bitsPerPixel;
final float frameRate = -1.f; // TODO

final int red;
final int green;
final int blue;

// QTSnapper returns BufferedImage.TYPE_INT_RGB
final int bufferedImageType = BufferedImage.TYPE_INT_RGB;

if (bufferedImageType == BufferedImage.TYPE_3BYTE_BGR)
{
	maxDataLength = qtSnapper.getImageWidth() * qtSnapper.getImageHeight() * 3; 
	dataType = Format.byteArray;
	bitsPerPixel = 24;
	red = 1;
	green = 2;
	blue = 3;
}
else if (bufferedImageType == BufferedImage.TYPE_INT_BGR)
{
	maxDataLength = qtSnapper.getImageWidth() * qtSnapper.getImageHeight(); 
	dataType = Format.intArray;
	bitsPerPixel = 32;	
	// TODO: test
	red = 0xFF;
	green = 0xFF00;	
	blue = 0xFF0000;
}
else if (bufferedImageType == BufferedImage.TYPE_INT_RGB)
{
	maxDataLength = qtSnapper.getImageWidth() * qtSnapper.getImageHeight(); 
	dataType = Format.intArray;
	bitsPerPixel = 32;	
	red = 0xFF0000;
	green = 0xFF00;
	blue = 0xFF;
}
else if (bufferedImageType == BufferedImage.TYPE_INT_ARGB)
{
	maxDataLength = qtSnapper.getImageWidth() * qtSnapper.getImageHeight(); 
	dataType = Format.intArray;
	bitsPerPixel = 32;	
	red = 0xFF0000;
	green = 0xFF00;
	blue = 0xFF;
	// just ignore alpha
}
else
	throw new IllegalArgumentException("Unsupported buffered image type: " + bufferedImageType);
	
return new RGBFormat(size, maxDataLength, dataType, frameRate, bitsPerPixel, red, green, blue);
  	
  }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:66,代码来源:QTParser.java

示例9: LiveStream

import javax.media.Format; //导入方法依赖的package包/类
public LiveStream() {
if (videoData) {
    int x, y, pos, revpos;
    
    size = new Dimension(320, 240);
    maxDataLength = size.width * size.height * 3;
    rgbFormat = new RGBFormat(size, maxDataLength,
			      Format.byteArray,
			      frameRate,
			      24,
			      3, 2, 1,
			      3, size.width * 3,
			      VideoFormat.FALSE,
			      Format.NOT_SPECIFIED);
    
    // generate the data
    data = new byte[maxDataLength];
    pos = 0;
    revpos = (size.height - 1) * size.width * 3;
    for (y = 0; y < size.height / 2; y++) {
	for (x = 0; x < size.width; x++) {
	    byte value = (byte) ((y*2) & 0xFF);
	    data[pos++] = value;
	    data[pos++] = 0;
	    data[pos++] = 0;
	    data[revpos++] = value;
	    data[revpos++] = 0;
	    data[revpos++] = 0;
	}
	revpos -= size.width * 6;
    }
} else { // audio data
    audioFormat = new AudioFormat(AudioFormat.LINEAR,
				  8000.0,
				  8,
				  1,
				  Format.NOT_SPECIFIED,
				  AudioFormat.SIGNED,
				  8,
				  Format.NOT_SPECIFIED,
				  Format.byteArray);
    maxDataLength = 1000;
}

thread = new Thread(this);
   }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:47,代码来源:LiveStream.java

示例10: process

import javax.media.Format; //导入方法依赖的package包/类
/**
 * Processes the data and renders it to a component
 */
public int process(Buffer buffer) {
	//logger.info("process...");

	if (buffer == null || buffer.getLength() <= 0) {
		//logger.info("zero length buffer");
		return BUFFER_PROCESSED_OK;
	}

	Format format = buffer.getFormat();
	if (format instanceof VideoFormat) {
		Dimension size = ((VideoFormat) format).getSize();
		if ((size != null) && (size.width != inWidth || size.height != inHeight)) {
			inWidth = size.width;
			inHeight = size.height;
			updateScale();
		}
	}

	synchronized (syncObject) {
		Object data = buffer.getData();
		if (data == null) {
			return BUFFER_PROCESSED_FAILED;
		}

		frameArray = buffer.getData();
		if (format.getDataType() == Format.byteArray) {
			frameData = ByteBuffer.wrap((byte[]) frameArray);
		}
		else if (format.getDataType() == Format.intArray) {
			frameData = IntBuffer.wrap((int[]) frameArray);
		}
		else {
			return BUFFER_PROCESSED_FAILED;
		}

		/*
		if (format.getDataType() == Format.byteArray) {
			if (frameArray == null || ((byte[])frameArray).length < buffer.getLength() ) {
				frameArray = new byte[buffer.getLength()];
				frameData = ByteBuffer.wrap((byte[]) frameArray);
			}
		}
		else if (format.getDataType() == Format.intArray) {
			if (frameArray == null || ((int[])frameArray).length < buffer.getLength() ) {
				frameArray = new int[buffer.getLength()];
				frameData = IntBuffer.wrap((int[]) frameArray);
			}
		}
		else {
			return BUFFER_PROCESSED_FAILED;
		}

		// copy buffer data to the array that is wrapped in a nio.Buffer
		System.arraycopy(data, 0, frameArray, 0, buffer.getLength());
		*/
	}

	// repaint the canvas
	canvas.repaint();

	return BUFFER_PROCESSED_OK;
}
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:66,代码来源:GlRenderer.java

示例11: drawImage

import javax.media.Format; //导入方法依赖的package包/类
private void drawImage(GL gl) {
	//logger.info("drawing video image");

	if (frameData == null) {
		return;
	}

	int rgbFormat = GL.GL_RGB;
	int dataType = GL.GL_UNSIGNED_BYTE;
	
	if (inputFormat.getDataType() == Format.byteArray) {
		dataType = GL.GL_UNSIGNED_BYTE;
	}
	else if (inputFormat.getDataType() == Format.intArray) {
		dataType = GL.GL_UNSIGNED_INT_8_8_8_8_REV;
	}
	
	switch (inputFormat.getBitsPerPixel()) {
		case 24:
			if (inputFormat.getRedMask() > 1) {
				rgbFormat = GL.GL_BGR;
			}
			else {
				rgbFormat = GL.GL_RGB;
			}
			break;
			
		case 32:
			if (inputFormat.getRedMask() > 0xFF) {
				rgbFormat = GL.GL_BGRA;
			}
			else {
				rgbFormat = GL.GL_RGBA;
			}
			break;
	}

	gl.glPixelZoom(zoomX, zoomY);
	gl.glRasterPos2i(-1, 1);
	gl.glDrawPixels(inWidth, inHeight, rgbFormat, dataType, frameData);
}
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:42,代码来源:GlRenderer.java


注:本文中的javax.media.Format.byteArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。