gpt4 book ai didi

android - 是否可以对一系列渲染脚本操作使用一次分配?

转载 作者:行者123 更新时间:2023-11-29 00:31:20 25 4
gpt4 key购买 nike

例如,我从位图进行分配,然后对其应用 brightnessContrastRs(),然后在该分配上使用类似实现的一些不同过滤器,通过 brightnessContrastRs() 操作更改?

public Bitmap brightnessContrastRs(Bitmap bmIn, int brightness, int contrast)
{
Bitmap bmOut = Bitmap.createBitmap(bmIn.getWidth(), bmIn.getHeight(),
bmIn.getConfig());
Allocation allocIn;
allocIn = Allocation.createFromBitmap(rs, bmIn,
Allocation.MipmapControl.MIPMAP_NONE,
Allocation.USAGE_SCRIPT);
Allocation allocOut = Allocation.createTyped(rs, allocIn.getType());

scriptCBrightnessContrast.set_in(allocIn);
allocIn.destroy();
scriptCBrightnessContrast.set_out(allocOut);
scriptCBrightnessContrast.set_script(scriptCBrightnessContrast);
float rowContrast = ((100.0f + contrast) * (100.0f + contrast) / 10000.0f);
float rowBrightness = brightness / 255.f;
scriptCBrightnessContrast.set_rowBrightness(rowBrightness);
scriptCBrightnessContrast.set_rowContrast(rowContrast);
scriptCBrightnessContrast.invoke_filter();
allocOut.copyTo(bmOut);
allocOut.destroy();
return bmOut;
}

RS 脚本:

rs_allocation out;
rs_allocation in;
rs_script script;

float rowBrightness;
float rowContrast;

void root(const uchar4* v_in, uchar4* v_out, const void* usrData, uint32_t x,
uint32_t y)
{
float4 current = rsUnpackColor8888(*v_in);

current.r = clamp(((clamp(current.r + rowBrightness, 0.0f, 1.0f) - 0.5f) * rowContrast + 0.5f), 0.0f, 1.0f);
current.g = clamp(((clamp(current.g + rowBrightness, 0.0f, 1.0f)- 0.5f) * rowContrast + 0.5f), 0.0f, 1.0f);
current.b = clamp(((clamp(current.b + rowBrightness, 0.0f, 1.0f) - 0.5f) * rowContrast + 0.5f), 0.0f, 1.0f);

*v_out = rsPackColorTo8888(current.r, current.g, current.b, current.a);
}
void filter()
{
#if !defined(RS_VERSION) || (RS_VERSION < 14)
rsForEach(script, in, out, 0);
#else
rsForEach(script, in, out);
#endif
}

最佳答案

您应该改用 ScriptGroup。

关于android - 是否可以对一系列渲染脚本操作使用一次分配?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15541265/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com