я есть попытаться создать синий растрового изображения, но он будет генерировать ошибку некоторые делают скриптКак создать Размытие растрового изображения в Android
private Bitmap blurRenderScript(Bitmap smallBitmap, int radius) {
try { smallBitmap = RGB565toARGB888(smallBitmap); } catch (Exception e) { e.printStackTrace(); }
Bitmap bitmap = Bitmap.createBitmap(smallBitmap.getWidth(),
smallBitmap.getHeight(), Bitmap.Config.ARGB_8888);
RenderScript renderScript = RenderScript.create(MainActivity.this);
Allocation blurInput = Allocation.createFromBitmap(renderScript,
smallBitmap); Allocation blurOutput = Allocation.createFromBitmap(renderScript,
bitmap);
ScriptIntrinsicBlur blur = ScriptIntrinsicBlur.create(renderScript,
Element.U8_4(renderScript)); blur.setInput(blurInput); blur.setRadius(radius); // radius must be 0 < r <= 25 blur.forEach(blurOutput);
blurOutput.copyTo(bitmap); renderScript.destroy();
return bitmap;
}
и вторая часть
private Bitmap RGB565toARGB888(Bitmap img) throws Exception { int numPixels = img.getWidth() * img.getHeight(); int[] pixels = new int[numPixels];
// Get JPEG pixels. Each int is the color values for one pixel. img.getPixels(pixels, 0, img.getWidth(), 0, 0, img.getWidth(),
img.getHeight());
// Create a Bitmap of the appropriate format. Bitmap result = Bitmap.createBitmap(img.getWidth(), img.getHeight(),
Bitmap.Config.ARGB_8888);
// Set RGB pixels. result.setPixels(pixels, 0, result.getWidth(), 0, 0, result.getWidth(),
result.getHeight()); return result; }
когда я вызова метод blurRenderScript(bitmap, 20)
он вызывает ошибку, подобную 10-06 11:40:33.547: E/RenderScript(13094): rsi_ScriptIntrinsicCreate 5 10-06 11:40:33.571: A/libc(13094): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=128), thread 13107
проверить эту удивительную библиотеку: [размыто] (https://github.com/wasabeef/Blurry) –