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
SwiftでWebPを使ってみた/melon-swift-webp
Search
Taketo Yoshida
July 14, 2016
Programming
1.6k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
SwiftでWebPを使ってみた/melon-swift-webp
http://fablic.connpass.com/event/35407/
で発表したLT資料です
Taketo Yoshida
July 14, 2016
More Decks by Taketo Yoshida
See All by Taketo Yoshida
Beautiful Japanese line break for the Web
tamanyan
1
590
新しい画像フォーマットHEIFを 用いたiOSアプリの通信量削減/iosdc-heif
tamanyan
9
6.8k
Source Code Generator for Team Development/code-generator-for-team-development
tamanyan
0
1.8k
How to Design Great Alerts/how-to-design-great-alerts
tamanyan
0
670
iOSエンジニアがReact-Nativeに触れてみた/ios-developer-react-native
tamanyan
0
510
フォーシームのスピン量とその効果/the-effect-of-fourseam-fastball-spin-rate
tamanyan
1
950
Objective-CからSwift移行を始めて感じた事/ObjC-to-Swift
tamanyan
1
1.5k
Modern and Practical Networking in Swift
tamanyan
2
840
まだJPEGで消耗してるの?/iOSDC-Reject-Conference
tamanyan
0
3.1k
Other Decks in Programming
See All in Programming
Family mrubyの進捗
kishima
1
110
LL言語やWebフレームワークのPostgreSQL対応 〜DBの機能がユーザーに届くまで〜
kentaroutakeda
0
150
Kiroで創り、AgentCoreで繋ぐ!AWSで実践する「AI-DLC」から「AIエージェント統合」までの最新地図
licux
3
520
AI に Inclusive UI を書かせよう — Design Rules Skill で Compose UI を作り直す
theoriatec2024
1
470
GKE で Pod の見方を変えたら、スケールアウト時の挙動を真に捉えられた話
stkk
0
110
ハーネス設計入門 〜プロンプト、コンテキストの次〜
kinopeee
55
37k
20260828_品質と開発生産性を両立させる、AI時代のE2Eテストの考え方
magicpod
0
180
思考垂れ流し開発 ~音声入力 × AIエージェント × 開発ハーネスによる試行錯誤~
npostring
0
1.1k
Claude Codeを組織的に動かして月400PRを実現した話
happy_ryo
0
270
標準パッケージに uuid が追加された 背景から見る Go らしい意思決定 / go_127_uuid_decision
convto
5
5.7k
[DroidKaigi 2026] Bring your own phones to Gradle Managed Devices
f2lk
0
110
AI × TiDD / 2026.09.05 Redmine 大阪
tokudiro
1
120
Featured
See All Featured
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
230
Paper Plane
katiecoart
PRO
3
53k
Six Lessons from altMBA
skipperchong
29
4.5k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
290
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
A Tale of Four Properties
chriscoyier
163
24k
Producing Creativity
orderedlist
PRO
348
41k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
240
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
67
58k
The SEO identity crisis: Don't let AI make you average
varn
0
550
Utilizing Notion as your number one productivity tool
mfonobong
4
580
BBQ
matthewcrist
89
10k
Transcript
!.FMPOTXJGU ٢ా݈ਓຊܦࡁ৽ฉࣾ 4XJGUͰ8FC1ΛͬͯΈͨ
2 ٢ా݈ਓʢ:PTIJEB5BLFUPʣ ຊܦࡁ৽ฉࣾͷJ04ΤϯδχΞ ࢴ໘ϏϡʔΞʔΞϓϦͷ։ൃ ϝϩϯ͖Ͱ͢ ࣗݾհ
ࠓJ04Ͱ8FC1Λ༻͢ΔΛ͠·͢ 3
4 (PPHMF͕։ൃ͍ͯ͠Δը૾ϑΥʔϚοτ ՄٯѹॖͱඇՄٯѹॖͷ྆ํΛαϙʔτ ඇՄٯѹॖͰ+1&(ͱൺͯখ͘͞ͳΔ 8FC1ͱʁ
None
6 8FC1,# +1&(,#
4XJGUͰ8FC1Λ͏ʹʁ 7
8 // To build libwebp $ brew install libtool $
brew install automake $ brew install autoconf // Create WebP.framework $ git clone https://chromium.googlesource.com/webm/libwebp $ git checkout 0.5.1 $ ./iosbuild.sh -> WebP.framework Add the WebP Header to your bridging header #include<WebP/decode.h>
9 private func freeImageData(info: UnsafeMutablePointer<Void>, data: UnsafePointer<Void>, size: Int) {
free(UnsafeMutablePointer<Void>(data)) } extension UIImage { static func imageFromWebPData(data: NSData) -> UIImage? { var config = WebPDecoderConfig() if WebPInitDecoderConfig(&config) == 0 { return nil } if WebPGetFeatures(UnsafePointer<UInt8>(data.bytes), data.length, &config.input) != VP8_STATUS_OK { return nil } config.output.colorspace = config.input.has_alpha != 0 ? MODE_rgbA : MODE_RGB if WebPDecode(UnsafePointer<UInt8>(data.bytes), data.length, &config) != VP8_STATUS_OK { return nil } let width = config.input.width let height = config.input.height let provider = CGDataProviderCreateWithData(nil, config.output.u.RGBA.rgba, config.output.u.RGBA.size, freeImageData) let colorSpaceRef = CGColorSpaceCreateDeviceRGB() let components = config.input.has_alpha != 0 ? 4 : 3 let bi = config.input.has_alpha != 0 ? CGBitmapInfo(rawValue: CGBitmapInfo.ByteOrderDefault.rawValue | CGImageAlphaInfo.PremultipliedLast.rawValue) : CGBitmapInfo.ByteOrderMask guard let imageRef = CGImageCreate( Int(width), Int(height), 8, components * 8, components * Int(width), colorSpaceRef, bi, provider, nil, true, .RenderingIntentDefault) else { return nil } return UIImage(CGImage: imageRef) } }
0CKFDUJWF$Ͱॻ͍ͨํ͕ॻ͖͍͢ 10
11 guard let url = NSURL(string: "path/to/image") else { return
} NSURLSession.sharedSession().dataTaskWithURL(url) { (data, response, error) in guard let data = data else { return } // Convert NSData to UIImage in Background Threads dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) { let image = UIImage.imageFromWebPData(data) ?? UIImage(data: data) // Handle image } }
ܦͰࢴ໘ϏϡʔΞʔͰ8FC1Λ༻ 12
13 ࢴ໘ΠϝʔδΛ8FC1Ͱ৴ +1&(ͱಉըૉͰݮ˞ ಉըૉͰϊΠζΛখ͘͞ ˞݄ͷேץͰଌఆ
ܦͰΤϯδχΞΛืूͯ͠·͢ 14 IUUQTTOJLLFJDPNTBJZP