platform thumbhash

This commit is contained in:
mertalev 2025-08-13 03:05:27 -04:00
parent 84462560e3
commit c988342de1
No known key found for this signature in database
GPG key ID: DF6ABC77AAD98C95
15 changed files with 581 additions and 44 deletions

View file

@ -47,6 +47,16 @@ class ThumbnailApiImpl: ThumbnailApi {
return assetCache
}()
func getThumbhash(thumbhash: String, completion: @escaping (Result<[String : Int64], any Error>) -> Void) {
Self.processingQueue.async {
guard let data = Data(base64Encoded: thumbhash)
else { return completion(.failure(PigeonError(code: "", message: "Invalid base64 string: \(thumbhash)", details: nil)))}
let (width, height, pointer) = thumbHashToRGBA(hash: data)
completion(.success(["pointer": Int64(Int(bitPattern: pointer.baseAddress)), "width": Int64(width), "height": Int64(height)]))
}
}
func requestImage(assetId: String, requestId: Int64, width: Int64, height: Int64, completion: @escaping (Result<[String: Int64], any Error>) -> Void) {
let request = Request(callback: completion)
let item = DispatchWorkItem {