简体   繁体   English

位图裁剪的渲染脚本

[英]Renderscript for Bitmap crop

It looks like Android SDK's BitmapRegionDecoder uses Skia for decoding a part of the specified bitmap. 看起来Android SDK的BitmapRegionDecoder使用Skia来解码指定位图的一部分。 Under the hood, it uses an appropriate code (jpeg, png etc) for the same. 在引擎盖下,它使用适当的代码(jpeg,png等)。 I'm looking at ways to optimize this using Renderscript. 我正在寻找使用Renderscript进行优化的方法。

Is it possible to define a Renderscript kernel function to ignore certain data from input allocation and save the rest in output allocation? 是否可以定义Renderscript内核函数以忽略输入分配中的某些数据并将其余数据保存在输出分配中? I'm new to Renderscript and most of the kernel function tends to work on the entire input data set. 我是Renderscript的新手,大多数内核函数都倾向于在整个输入数据集上工作。

Yes, use the LaunchOptions API to limit the rectangle that you launch over: 是的,请使用LaunchOptions API来限制您通过其启动的矩形:

Script.LaunchOptions lo;
lo.setX(10, 100);
lo.setY(5, 20);
kernel.forEach(in, out, lo);

https://developer.android.com/reference/android/renderscript/Script.LaunchOptions.html https://developer.android.com/reference/android/renderscript/Script.LaunchOptions.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM