小编Vin*_*ile的帖子

从位图分配Renderscript

我正试图进入渲染脚本,并对分配使用感到困惑.几乎所有示例都显示了下一个算法:

  1. 创建进出位图
  2. 相应地从位图输入和输出创建输入和输出分配
  3. 配置脚本并执行forEach方法
  4. 使用copyTo方法将Out out的结果复制到位图中

像这样的东西:

    Bitmap srcBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.lena);
    Bitmap dstBitmap = Bitmap.createBitmap(srcBitmap.getWidth(), srcBitmap.getHeight(), srcBitmap.getConfig());

    Allocation allocationIn = Allocation.createFromBitmap(renderScript, srcBitmap);
    Allocation allocationOut = Allocation.createFromBitmap(renderScript, dstBitmap);

    scriptColorMatrix.setGreyscale();

    scriptColorMatrix.forEach(allocationIn, allocationOut);

    //no difference after removing this line
    allocationOut.copyTo(dstBitmap);

    imagePreview.setImageBitmap(dstBitmap);
Run Code Online (Sandbox Code Playgroud)

这有效,但即使我通过删除省略步骤4也可以工作:

allocationOut.copyTo(dstBitmap);
Run Code Online (Sandbox Code Playgroud)

让我们进一步降低灰度后的亮度:

    Bitmap srcBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.lena);
    Bitmap dstBitmap = Bitmap.createBitmap(srcBitmap.getWidth(), srcBitmap.getHeight(), srcBitmap.getConfig());

    Allocation allocationIn = Allocation.createFromBitmap(renderScript, srcBitmap);
    Allocation allocationOut = Allocation.createFromBitmap(renderScript, dstBitmap);

    scriptColorMatrix.setGreyscale();

    scriptColorMatrix.forEach(allocationIn, allocationOut);

    //reset color matrix
    scriptColorMatrix.setColorMatrix(new Matrix4f());

    //adjust brightness
    scriptColorMatrix.setAdd(-0.5f, -0.5f, -0.5f, 0f);

    //Performing forEach vise …
Run Code Online (Sandbox Code Playgroud)

android renderscript

2
推荐指数
1
解决办法
1304
查看次数

使用 Azure 托管服务标识连接到 Cosmos DB 帐户

是否可以使用与 Azure SQL 相同的方式使用 MSI 连接到 Azure Cosmos DB?

这就是 Azure SQL Server 的工作原理

using (var connection = new SqlConnection(connectionString))
{
    connection.AccessToken = await new AzureServiceTokenProvider().GetAccessTokenAsync("https://database.windows.net/");
    await connection.OpenAsync(cancellationToken);

    //...
}
Run Code Online (Sandbox Code Playgroud)

我无法为 Cosmos DB 找到任何类似的东西。虽然 MSI 对它的支持似乎已启用

.net azure azure-cosmosdb azure-managed-identity

2
推荐指数
1
解决办法
2126
查看次数