Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
RenderScript for Android
Search
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
340
2023 Flutter/Dart Summary
wasabeef
0
140
I/O Extended 2023 - Dart と Flutter の新機能
wasabeef
0
250
I/O Extended 2023 - Flutter 活用事例
wasabeef
10
3.1k
What it Takes to be a Flutter Developer
wasabeef
0
270
FlutterKaigi 2022 Keynote
wasabeef
1
760
Flutter Hooks を使ったアプリ開発 / App Development with the Flutter Hooks
wasabeef
2
1.6k
Flutter 2021 の振り返りと今後のアプリ開発に向けて / Looking back on Flutter 2021 and for future app development.
wasabeef
4
2.3k
Other Decks in Programming
See All in Programming
Jetpack Compose メカニズム
skydoves
0
470
SONY CISC-NEWS NWS-1750 + NWB-225 フレームバッファの NetBSD/news68k ドライバ実装 / OSC2026Hiroshima
tsutsui
0
140
【高い買い物LT会】初任給で話題の国産フィジカルAIを買った話
akagami
PRO
0
170
Ghostty + Neovimで作る 透明でカッコ良い開発環境
j341nono
0
120
The Rails Doctrine Decade
koic
2
340
AI活用は、個人から組織へ|マルチプレイヤーエージェントハーネス「QM」の社内活用事例 / AI use is moving from individuals to orgs
rkaga
1
170
AI が書く Go コードの品質を劇的に向上させる Linter: “declscope”
mpyw
0
380
個人開発基盤をまるごとCloudflareに引っ越して爆速で総合的体験を向上させた話
tinykitten
0
200
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
660
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
530
AGENTS.md Is Not Enough:Build Skills, Don't Download Them
lx_t
0
130
スマート反転とウェブアクセシビリティ
camiha
0
210
Featured
See All Featured
Statistics for Hackers
jakevdp
799
230k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
600
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Six Lessons from altMBA
skipperchong
29
4.5k
Designing Powerful Visuals for Engaging Learning
tmiket
1
580
Bash Introduction
62gerente
615
220k
Navigating Weather and Climate Data
rabernat
0
530
It's Worth the Effort
3n
188
29k
Claude Code のすすめ
schroneko
67
230k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
300
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.3k
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.