當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。