简体   繁体   中英

Renderscript for Bitmap crop

It looks like Android SDK's BitmapRegionDecoder uses Skia for decoding a part of the specified bitmap. Under the hood, it uses an appropriate code (jpeg, png etc) for the same. I'm looking at ways to optimize this using Renderscript.

Is it possible to define a Renderscript kernel function to ignore certain data from input allocation and save the rest in output allocation? I'm new to Renderscript and most of the kernel function tends to work on the entire input data set.

Yes, use the LaunchOptions API to limit the rectangle that you launch over:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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