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


Java Allocation.copyFromUnchecked方法代码示例

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


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

示例1: convertYuv420ToBitmap

import android.support.v8.renderscript.Allocation; //导入方法依赖的package包/类
private static Bitmap convertYuv420ToBitmap(Image image) {
    RenderScript rs = mRenderScript;
    final int width = image.getWidth();
    final int height = image.getHeight();

    // prepare input Allocation for RenderScript
    Type.Builder inType = new Type.Builder(rs, Element.U8(rs)).setX(width).setY(height).setYuvFormat(ImageFormat.YV12);
    Allocation inAlloc = Allocation.createTyped(rs, inType.create(), Allocation.USAGE_SCRIPT);
    byte[] rawBuffer = new byte[inAlloc.getBytesSize()];
    int lumaSize = width * height;
    int chromaSize = (width / 2) * (height / 2);
    Image.Plane[] planes = image.getPlanes();
    planes[0].getBuffer().get(rawBuffer, 0, lumaSize);
    planes[1].getBuffer().get(rawBuffer, lumaSize, chromaSize);
    planes[2].getBuffer().get(rawBuffer, lumaSize + chromaSize, chromaSize);
    inAlloc.copyFromUnchecked(rawBuffer);

    // prepare output Allocation for RenderScript
    Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Allocation outAlloc = Allocation.createFromBitmap(rs, bmp, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT | Allocation.USAGE_SHARED);

    // convert YUV to RGB colorspace
    ScriptC_yuv2rgb converter = new ScriptC_yuv2rgb(rs);
    converter.set_gYUV(inAlloc);
    converter.forEach_convert(outAlloc);
    outAlloc.copyTo(bmp);
    return bmp;
}
 
开发者ID:yohhoy,项目名称:heifreader,代码行数:29,代码来源:HeifReader.java

示例2: createAllocation

import android.support.v8.renderscript.Allocation; //导入方法依赖的package包/类
public Allocation createAllocation(RenderScript rs) {
    final int sx = xSize;
    final int sy = ySize;
    final int sz = zSize;
    Type.Builder tb = new Type.Builder(rs, Element.U8_4(rs));
    tb.setX(sx);
    tb.setY(sy);
    tb.setZ(sz);
    Type t = tb.create();
    Allocation mCube = Allocation.createTyped(rs, t);
    mCube.copyFromUnchecked(getCube());

    return mCube;
}
 
开发者ID:silvaren,项目名称:easyrs,代码行数:15,代码来源:Lut3DParams.java

示例3: encodeImage

import android.support.v8.renderscript.Allocation; //导入方法依赖的package包/类
/**
 * Encode an entire image. pIn - pointer to the image data. Formatted such
 * that the Red component of pixel (x,y) is at pIn + pixelSize * x + stride
 * * y + redOffset; pOut - pointer to encoded data. Must be large enough to
 * store entire encoded image.
 * @param script 
 * @param containMipmaps 
 */
public static int encodeImage(RenderScript rs, ScriptC_etc1compressor script, Allocation aIn, int width, int height,
		int pixelSize, int stride, ByteBuffer compressedImage, ByteBuffer compressedAlphaImage, boolean containMipmaps, boolean hasAlpha) {
	
	long tInitArray = java.lang.System.currentTimeMillis();
	
	script.set_height(height);
	script.set_width(width);
	script.set_containMipmaps(containMipmaps);
	script.set_pixelSize(pixelSize);
	script.set_hasAlpha(hasAlpha);
	
	if (pixelSize < 2 || pixelSize > 4) {
		return -1;
	}
	
	// int iOut = 0;
	
	int size = Math.max(aIn.getBytesSize() / ((DECODED_BLOCK_SIZE/3)*pixelSize), 1);
	Allocation aout = Allocation.createSized(rs, Element.U16_4(rs), size);
	
	Allocation aoutAlpha = Allocation.createSized(rs, Element.U8(rs), 8*size);
	
	tInitArray = java.lang.System.currentTimeMillis() - tInitArray;
	//System.out.println("tInitArray : "+tInitArray+" ms");
	
	long tFillAlloc = java.lang.System.currentTimeMillis();		
	script.bind_pInA(aIn);		
	script.bind_outAlpha(aoutAlpha);		
	tFillAlloc = java.lang.System.currentTimeMillis() - tFillAlloc;
	//System.out.println("tFillAlloc : "+tFillAlloc+" ms");
	
	long tExec = java.lang.System.currentTimeMillis();
	script.forEach_root(aout);
	tExec = java.lang.System.currentTimeMillis() - tExec;
	//System.out.println("tExec : "+tExec+" ms");
	
	long tFillOut = java.lang.System.currentTimeMillis();
	
	short[] arrayOut3Temp = new short[4*size];
	aout.copyTo(arrayOut3Temp);
	aout.destroy();
	
	Allocation aout2 = Allocation.createSized(rs, Element.U8(rs), 8*size);
	aout2.copyFromUnchecked(arrayOut3Temp);

	aout2.copyTo(compressedImage.array());	
	aout2.destroy();
	
	if(hasAlpha) {
		aoutAlpha.copyTo(compressedAlphaImage.array());				
	}
	aoutAlpha.destroy();
	
	tFillOut = java.lang.System.currentTimeMillis() - tFillOut;
	
	compressedImage.rewind();
	
	//System.out.println("tFillOut : "+tFillOut+" ms");
	
	return 0;
}
 
开发者ID:nicastel,项目名称:renderscript_texture_compressor,代码行数:70,代码来源:RsETC1.java


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