我正试图进入渲染脚本,并对分配使用感到困惑.几乎所有示例都显示了下一个算法:
像这样的东西:
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) 是否可以使用与 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 对它的支持似乎已启用