本文整理汇总了Java中android.renderscript.Type类的典型用法代码示例。如果您正苦于以下问题:Java Type类的具体用法?Java Type怎么用?Java Type使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Type类属于android.renderscript包,在下文中一共展示了Type类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createType
import android.renderscript.Type; //导入依赖的package包/类
public static Type createType(RenderScript rs, Element e, int x, int y) {
if (Build.VERSION.SDK_INT >= 21) {
return Type.createXY(rs, e, x, y);
} else {
return new Type.Builder(rs, e).setX(x).setY(y).create();
}
}
示例2: createYuvType
import android.renderscript.Type; //导入依赖的package包/类
@RequiresApi(18)
public static Type createYuvType(RenderScript rs, int x, int y, int yuvFormat) {
boolean supported = yuvFormat == ImageFormat.NV21 || yuvFormat == ImageFormat.YV12;
if (Build.VERSION.SDK_INT >= 19) {
supported |= yuvFormat == ImageFormat.YUV_420_888;
}
if (!supported) {
throw new IllegalArgumentException("invalid yuv format: " + yuvFormat);
}
return new Type.Builder(rs, createYuvElement(rs)).setX(x).setY(y).setYuvFormat(yuvFormat)
.create();
}
示例3: heal
import android.renderscript.Type; //导入依赖的package包/类
/**
* This function only assumes mPointsXY, mPasteOffX, mPasteOffY
*
* @param healing
* @param rs
* @param image
*/
public void heal(ScriptC_healing healing, RenderScript rs, Bitmap image, Bitmap output) {
long time = System.nanoTime();
Type.Builder floatImage = new Type.Builder(rs, Element.F32_3(rs));
floatImage.setX(mRoiBounds.width());
floatImage.setY(mRoiBounds.height());
Bitmap mask_bitmap = buildMask(mRoiBounds, mPointsXY);
Bitmap dest_bitmap = createMutableBitmap(image, mRoiBounds.left, mRoiBounds.top,
mRoiBounds.width(), mRoiBounds.height());
Allocation dest_alloc = Allocation.createFromBitmap(rs, dest_bitmap);
Bitmap src_bitmap = createMutableBitmap(image, mCutOffsetX, mCutOffsetY,
mRoiBounds.width(), mRoiBounds.height());
Allocation src_alloc = Allocation.createFromBitmap(rs, src_bitmap);
Allocation mask_alloc = Allocation.createFromBitmap(rs, mask_bitmap);
healing.invoke_heal(mask_alloc, src_alloc, dest_alloc);
dest_alloc.copyTo(dest_bitmap);
dest_bitmap.setHasAlpha(true);
// build the undo
mUndoBitmap = Bitmap.createBitmap(mRoiBounds.width(), mRoiBounds.height(),
Bitmap.Config.ARGB_8888);
Canvas undoCanvas = new Canvas(mUndoBitmap);
Rect undoRect = new Rect(0, 0, mRoiBounds.width(), mRoiBounds.height());
undoCanvas.drawBitmap(output, mRoiBounds, undoRect, null);
Canvas c = new Canvas(output);
c.drawBitmap(image, 0, 0, null);
c.drawBitmap(dest_bitmap, mRoiBounds.left, mRoiBounds.top, null);
Log.v(TAG, " time ss to smart paste = " + (System.nanoTime() - time) / 1E6f + "ms");
heal_orig(healing, rs, image, output);
}
示例4: allocFloat2
import android.renderscript.Type; //导入依赖的package包/类
Allocation allocFloat2(float[] p, RenderScript rs) {
Type.Builder builderF32_2 = new Type.Builder(rs, Element.F32_2(rs));
builderF32_2.setX(p.length / 2);
Allocation ret = Allocation.createTyped(rs, builderF32_2.create());
ret.copyFrom(p);
return ret;
}
示例5: initializeParamsAllocation
import android.renderscript.Type; //导入依赖的package包/类
private void initializeParamsAllocation() {
Type wInType = Type.createXY(mRs, Element.F32(mRs), hidden_units, inDim);
Allocation wInAlloc = Allocation.createTyped(mRs, wInType);
wInAlloc.copyFrom(convertedWIn);
scriptC_main.set_w_in(wInAlloc);
Allocation bInAlloc = Allocation.createSized(mRs, Element.F32(mRs), hidden_units);
bInAlloc.copyFrom(b_in);
scriptC_main.set_b_in(bInAlloc);
Type wOutType = Type.createXY(mRs, Element.F32(mRs), outDim, hidden_units);
Allocation wOutAlloc = Allocation.createTyped(mRs, wOutType);
wOutAlloc.copyFrom(convertedWOut);
scriptC_main.set_w_out(wOutAlloc);
Allocation bOutAlloc = Allocation.createSized(mRs, Element.F32(mRs), outDim);
bOutAlloc.copyFrom(b_out);
scriptC_main.set_b_out(bOutAlloc);
Type weightType = Type.createXYZ(mRs, Element.F32(mRs),
hidden_units * 4, hidden_units * 2, layerSize);
Allocation weightAlloc = Allocation.createTyped(mRs, weightType);
weightAlloc.copyFrom(convertedWeights);
scriptC_main.set_weights(weightAlloc);
Type biasType = Type.createXY(mRs, Element.F32(mRs), hidden_units * 4, layerSize);
Allocation biasAlloc = Allocation.createTyped(mRs, biasType);
biasAlloc.copyFrom(convertedBiases);
scriptC_main.set_biases(biasAlloc);
}
示例6: config
import android.renderscript.Type; //导入依赖的package包/类
protected void config(){
opt.setX(0,height);
Type.Builder builder = new Type.Builder(rs, Element.F32(rs));
builder.setX(height);
out = Allocation.createTyped(rs,builder.create());
rsSum.set_g_x_start(0);
rsSum.set_g_x_end(width);
rsSum.set_g_src(parameter.allocIn);
}
示例7: createAllocOutEstimateErr
import android.renderscript.Type; //导入依赖的package包/类
private void createAllocOutEstimateErr(){
Type.Builder builder = new Type.Builder(rs, Element.F32(rs));
builder.setX(curRect.width() + 1);
builder.setY(curRect.height()+1);
Type type = builder.create();
outErr = Allocation.createTyped(rs,type);
}
示例8: allocGray
import android.renderscript.Type; //导入依赖的package包/类
static private void allocGray(){
Type.Builder builder = new Type.Builder(rs,Element.I32(rs));
builder.setX(data.getOriWidth());
builder.setY(data.getOriHeight());
allocGrayBase = Allocation.createTyped(rs,builder.create());
allocGrayCur = Allocation.createTyped(rs,builder.create());
}
示例9: allocPartial
import android.renderscript.Type; //导入依赖的package包/类
static private void allocPartial(){
Type.Builder builder = new Type.Builder(rs,Element.I32(rs));
builder.setX(data.getOriWidth());
builder.setY(data.getOriHeight());
allocBasePartialX = Allocation.createTyped(rs,builder.create());
allocBasePartialY = Allocation.createTyped(rs,builder.create());
}
示例10: allocSecPartial
import android.renderscript.Type; //导入依赖的package包/类
static private void allocSecPartial(){
Type.Builder builder = new Type.Builder(rs,Element.F32(rs));
builder.setX(data.getOriWidth());
builder.setY(data.getOriHeight());
allocBaseSecPartialX = Allocation.createTyped(rs,builder.create());
allocBaseSecPartialY = Allocation.createTyped(rs,builder.create());
}
示例11: createFilter
import android.renderscript.Type; //导入依赖的package包/类
@Override
protected void createFilter(android.content.res.Resources res, float scaleFactor,
int quality, Allocation in) {
RenderScript rsCtx = getRenderScriptContext();
Type.Builder tb_float = new Type.Builder(rsCtx, Element.F32_4(rsCtx));
tb_float.setX(in.getType().getX());
tb_float.setY(in.getType().getY());
mScript = new ScriptC_saturation(rsCtx, res, R.raw.saturation);
}
示例12: createFilter
import android.renderscript.Type; //导入依赖的package包/类
@Override
protected void createFilter(android.content.res.Resources res, float scaleFactor,
int quality, Allocation in) {
RenderScript rsCtx = getRenderScriptContext();
Type.Builder tb_float = new Type.Builder(rsCtx, Element.F32_4(rsCtx));
tb_float.setX(in.getType().getX());
tb_float.setY(in.getType().getY());
mScript = new ScriptC_grad(rsCtx, res, R.raw.grad);
}
示例13: Camera2Callback
import android.renderscript.Type; //导入依赖的package包/类
public Camera2Callback()
//----------------------
{
rs = RenderScript.create(activity);
switch (fileFormat)
{
case YUV_420:
YUVToRGBA = ScriptIntrinsicYuvToRGB.create(rs, Element.RGBA_8888(rs));
Type.Builder yuvTypeBuilder = new Type.Builder(rs, Element.YUV(rs));
yuvTypeBuilder.setX(previewWidth).setY(previewHeight).setYuvFormat(ImageFormat.YUV_420_888);
ain = Allocation.createTyped(rs, yuvTypeBuilder.create(), Allocation.USAGE_SCRIPT);
Type.Builder rgbTypeBuilder = new Type.Builder(rs, Element.RGBA_8888(rs));
rgbTypeBuilder.setX(previewWidth).setY(previewHeight);
aOut = Allocation.createTyped(rs, rgbTypeBuilder.create(), Allocation.USAGE_SCRIPT);
break;
case NV21:
YUVToRGBA = ScriptIntrinsicYuvToRGB.create(rs, Element.U8_4(rs));
Type.Builder yuvType = new Type.Builder(rs, Element.U8(rs)).setX(previewWidth).
setY(previewHeight).setMipmaps(false).setYuvFormat(ImageFormat.NV21);
Type.Builder rgbaType = new Type.Builder(rs, Element.RGBA_8888(rs)).setX(previewWidth).
setY(previewHeight).setMipmaps(false);
ain = Allocation.createTyped(rs, yuvType.create(), Allocation.USAGE_SCRIPT);
aOut = Allocation.createTyped(rs, rgbaType.create(), Allocation.USAGE_SCRIPT);
break;
}
}
示例14: toRGBA
import android.renderscript.Type; //导入依赖的package包/类
public byte[] toRGBA(Context context, byte[] frame, int previewWidth, int previewHeight, int rgbaSize, byte[] grey)
//----------------------------------------------------------------------------------------------------------------
{
try
{
final int inputFormat = ImageFormat.YUV_420_888;
Type.Builder yuvTypeBuilder = new Type.Builder(renderscript, Element.YUV(renderscript));
yuvTypeBuilder.setX(previewWidth).setY(previewHeight).setYuvFormat(inputFormat);
Allocation allocYUVIn = Allocation.createTyped(renderscript, yuvTypeBuilder.create(), Allocation.USAGE_SCRIPT);
Type.Builder rgbTypeBuilder = new Type.Builder(renderscript, Element.RGBA_8888(renderscript));
rgbTypeBuilder.setX(previewWidth).setY(previewHeight);
Allocation allocRGBAOut = Allocation.createTyped(renderscript, rgbTypeBuilder.create(), Allocation.USAGE_SCRIPT);
ScriptIntrinsicYuvToRGB YUVToRGB = ScriptIntrinsicYuvToRGB.create(renderscript, Element.RGBA_8888(renderscript));
allocYUVIn.copyFrom(frame);
YUVToRGB.setInput(allocYUVIn);
YUVToRGB.forEach(allocRGBAOut);
byte[] rgbaBuffer = new byte[rgbaSize];
allocRGBAOut.copyTo(rgbaBuffer);
if (grey != null)
{
Type.Builder greyTypeBuilder = new Type.Builder(renderscript, Element.U8(renderscript));
greyTypeBuilder.setX(cameraWidth).setY(cameraHeight);
Allocation allocGrayOut = Allocation.createTyped(renderscript, greyTypeBuilder.create(), Allocation.USAGE_SCRIPT);
ScriptC_yuv2grey rsYUVtoGrey = new ScriptC_yuv2grey(renderscript);
allocYUVIn.copyFrom(frame);
rsYUVtoGrey.set_in(allocYUVIn);
rsYUVtoGrey.forEach_yuv2grey(allocGrayOut);
allocGrayOut.copyTo(grey);
}
return rgbaBuffer;
}
catch (Exception e)
{
Log.e(LOGTAG, "", e);
return null;
}
}
示例15: createPreviewAllocation
import android.renderscript.Type; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public Allocation createPreviewAllocation(RenderScript rs, int usage) throws RSIllegalArgumentException
//------------------------------------------------------------------------------------------------------
{
Type.Builder yuvBuilder = new Type.Builder(rs, Element.createPixel(rs, Element.DataType.UNSIGNED_8,
Element.DataKind.PIXEL_YUV)
);
yuvBuilder.setYuvFormat(ImageFormat.YV12);
yuvBuilder.setX(previewWidth);
yuvBuilder.setY(previewHeight);
Allocation a = Allocation.createTyped(rs, yuvBuilder.create(), usage | Allocation.USAGE_IO_INPUT);
return a;
}