Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
RenderScript for Android
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Daichi Furiya (Wasabeef)
September 29, 2015
Programming
2.2k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
RenderScript for Android
RenderScript + Blur
Daichi Furiya (Wasabeef)
September 29, 2015
More Decks by Daichi Furiya (Wasabeef)
See All by Daichi Furiya (Wasabeef)
DevFest Tokyo 2025 - Flutter のアプリアーキテクチャ現在地点
wasabeef
6
2.9k
About Flutter Architecture
wasabeef
1
330
2023 Flutter/Dart Summary
wasabeef
0
140
I/O Extended 2023 - Dart と Flutter の新機能
wasabeef
0
240
I/O Extended 2023 - Flutter 活用事例
wasabeef
10
3.1k
What it Takes to be a Flutter Developer
wasabeef
0
260
FlutterKaigi 2022 Keynote
wasabeef
1
740
Flutter Hooks を使ったアプリ開発 / App Development with the Flutter Hooks
wasabeef
2
1.5k
Flutter 2021 の振り返りと今後のアプリ開発に向けて / Looking back on Flutter 2021 and for future app development.
wasabeef
4
2.2k
Other Decks in Programming
See All in Programming
PyConJP2026_wat_Python × Signal Processing: How to Draw Pictures with Sound Using Spectrogram Art
wat
0
290
書籍「プロフェッショナルAI駆動開発」紹介スライド
juntaromatsumoto
0
340
2年かけて Deno に DOMMatrix を実装した話 / How I implemented DOMMatrix in Deno over two years
petamoriken
0
220
仕様書を書く前にハーネスを作る - Agent Native開発は「探索を速く、判定を固く」
gotalab555
4
1.7k
仕様駆動開発へのトライを機に チームに適合する手法を模索し続けている話
freee
PRO
0
590
Claude CodeとAgentCore Gatewayを繋ぐ際の認証認可 / Authentication and authorization when connecting Claude Code with AgentCore Gateway
har1101
2
360
Flow は今どうなっているか
mizdra
PRO
0
680
How I Won Prize Money at a Hackathon Using Codex and Symphony Alpha
yasei_no_otoko
0
120
Gmail/Google DriveをトリガーにAIエージェントを動かそう! / Run AI agents with Gmail/Google Drive as triggers!
har1101
2
430
為什麼你並不需要ViewModel / No, you don't need a ViewModel
lovee
1
510
仕様駆動開発の消費期限
watany
20
8.9k
思考垂れ流し開発 ~音声入力 × AIエージェント × 開発ハーネスによる試行錯誤~
npostring
0
120
Featured
See All Featured
Why Our Code Smells
bkeepers
PRO
340
58k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
950
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
440
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.5k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
201
75k
Writing Fast Ruby
sferik
630
63k
How Software Deployment tools have changed in the past 20 years
geshan
1
34k
Designing for Performance
lara
611
70k
Heart Work Chapter 1 - Part 1
lfama
PRO
8
36k
We Have a Design System, Now What?
morganepeng
55
8.3k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Transcript
RenderScript + Blur Wasabeef
About Me @wasabeef_jp CyberAgent, Inc.
RenderScript?
RenderScript? ɾAPI Level 11 (Support Library v8) ɾUsing C99 lang
(RenderScript Kernel) ɾUsing Java API ɾImage Processing ɾBlur … etc
RenderScript Kernel? blur.rs LLVM RS CC blur.bc ScriptC_blur .java ScriptField_point
.java
RenderScript Intrinsics ɾScriptIntrinsicConvolve3x3 ɾScriptIntrinsicConvolve5x5 ɾScriptIntrinsicBlur ɾScriptIntrinsicYuvToRGB ɾScriptIntrinsicColorMatrix ɾScriptIntrinsicBlend ɾScriptIntrinsicLUT ɾScriptIntrinsic3DLUT
RenderScript Settings
Gradle android { compileSdkVersion 23 buildToolsVersion “23.0.1” defaultConfig { minSdkVersion
23 targetSdkVersion 23 renderscriptTargetApi 23 renderscriptSupportModeEnabled true } }
Gradle android { compileSdkVersion 23 buildToolsVersion “23.0.1” defaultConfig { minSdkVersion
23 targetSdkVersion 23 renderscriptTargetApi 23 renderscriptSupportModeEnabled true } }
Blur?
Blur
Algorithms ɾRS Gaussian Fast (ScriptIntrinsicBlur) ɾRS Box, Gaussian 5x5 (ScriptIntrinsicConvolve5x5)
ɾStack Blur ɾGaussian Fast Blur ɾBox Blur
Gaussian Blur (Java) public static void blur(Bitmap bmp, int radius)
{ int w = bmp.getWidth(); int h = bmp.getHeight(); int[] pix = new int[w * h]; bmp.getPixels(pix, 0, w, 0, 0, w, h); for (int r = radius; r >= 1; r /= 2) { for (int i = r; i < h - r; i++) { for (int j = r; j < w - r; j++) { int tl = pix[(i - r) * w + j - r]; int tr = pix[(i - r) * w + j + r]; int tc = pix[(i - r) * w + j]; int bl = pix[(i + r) * w + j - r]; int br = pix[(i + r) * w + j + r]; int bc = pix[(i + r) * w + j]; int cl = pix[i * w + j - r]; int cr = pix[i * w + j + r]; pix[(i * w) + j] = 0xFF000000 | (((tl & 0xFF) + (tr & 0xFF) + (tc & 0xFF) + (bl & 0xFF) + (br & 0xFF) + (bc & 0xFF) + (cl & 0xFF) + (cr & 0xFF)) >> 3) & 0xFF | (((tl & 0xFF00) + (tr & 0xFF00) + (tc & 0xFF00) + (bl & 0xFF00) + (br & 0xFF00) + (bc & 0xFF00) + (cl & 0xFF00) + (cr & 0xFF00)) >> 3) & 0xFF00 | (((tl & 0xFF0000) + (tr & 0xFF0000) + (tc & 0xFF0000) + (bl & 0xFF0000) + (br & 0xFF0000) + (bc & 0xFF0000) + (cl & 0xFF0000) + (cr & 0xFF0000)) >> 3) & 0xFF0000; } } } bmp.setPixels(pix, 0, w, 0, 0, w, h); }
RS Gaussian Blur (Java) public static void blur(Bitmap src, int
radius) { RenderScript rs = RenderScript.create(context); Allocation input = Allocation.createFromBitmap(rs, src); Allocation output = Allocation.createTyped(rs, input.getType()); ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs)); script.setRadius(radius); script.setInput(input); script.forEach(output); output.copyTo(src); rs.destroy(); }
RenderScript public static void blur(Bitmap src, int radius) { RenderScript
rs = RenderScript.create(context); Allocation input = Allocation.createFromBitmap(rs, src); Allocation output = Allocation.createTyped(rs, input.getType()); ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs)); script.setRadius(radius); script.setInput(input); script.forEach(output); output.copyTo(src); rs.destroy(); }
Allocation public static void blur(Bitmap src, int radius) { RenderScript
rs = RenderScript.create(context); Allocation input = Allocation.createFromBitmap(rs, src); Allocation output = Allocation.createTyped(rs, input.getType()); ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs)); script.setRadius(radius); script.setInput(input); script.forEach(output); output.copyTo(src); rs.destroy(); }
ScriptIntrinsicBlur public static void blur(Bitmap src, int radius) { RenderScript
rs = RenderScript.create(context); Allocation input = Allocation.createFromBitmap(rs, src); Allocation output = Allocation.createTyped(rs, input.getType()); ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs)); script.setRadius(radius); script.setInput(input); script.forEach(output); output.copyTo(src); rs.destroy(); }
RenderScript Intrinsics ɾScriptIntrinsicConvolve3x3 ɾScriptIntrinsicConvolve5x5 ɾScriptIntrinsicBlur ɾScriptIntrinsicYuvToRGB ɾScriptIntrinsicColorMatrix ɾScriptIntrinsicBlend ɾScriptIntrinsicLUT ɾScriptIntrinsic3DLUT
Element ɾRoughly equivalent to a C type ɾfloat ɾfloat4 ɾunsigned
32-bit int ɾsigned 8-bit int
ScriptIntrinsicBlur::setRadius public static void blur(Bitmap src, int radius) { RenderScript
rs = RenderScript.create(context); Allocation input = Allocation.createFromBitmap(rs, src); Allocation output = Allocation.createTyped(rs, input.getType()); ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs)); script.setRadius(radius); script.setInput(input); script.forEach(output); output.copyTo(src); rs.destroy(); }
ScriptIntrinsicBlur::setInput public static void blur(Bitmap src, int radius) { RenderScript
rs = RenderScript.create(context); Allocation input = Allocation.createFromBitmap(rs, src); Allocation output = Allocation.createTyped(rs, input.getType()); ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs)); script.setRadius(radius); script.setInput(input); script.forEach(output); output.copyTo(src); rs.destroy(); }
ScriptIntrinsicBlur::forEach public static void blur(Bitmap src, int radius) { RenderScript
rs = RenderScript.create(context); Allocation input = Allocation.createFromBitmap(rs, src); Allocation output = Allocation.createTyped(rs, input.getType()); ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs)); script.setRadius(radius); script.setInput(input); script.forEach(output); output.copyTo(src); rs.destroy(); }
Allocation::copyTo public static void blur(Bitmap src, int radius) { RenderScript
rs = RenderScript.create(context); Allocation input = Allocation.createFromBitmap(rs, src); Allocation output = Allocation.createTyped(rs, input.getType()); ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs)); script.setRadius(radius); script.setInput(input); script.forEach(output); output.copyTo(src); rs.destroy(); }
RenderScript::destroy public static void blur(Bitmap src, int radius) { RenderScript
rs = RenderScript.create(context); Allocation input = Allocation.createFromBitmap(rs, src); Allocation output = Allocation.createTyped(rs, input.getType()); ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs)); script.setRadius(radius); script.setInput(input); script.forEach(output); output.copyTo(src); rs.destroy(); }
RS Gaussian Blur public static void blur(Bitmap src, int radius)
{ RenderScript rs = RenderScript.create(context); Allocation input = Allocation.createFromBitmap(rs, src); Allocation output = Allocation.createTyped(rs, input.getType()); ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs)); script.setRadius(radius); script.setInput(input); script.forEach(output); output.copyTo(src); rs.destroy(); }
github.com/wasabeef Blurry Glide Transformations Picasso Transformations Fresco Processors
Thanks.