BlurHash拍摄了一个图像,给你一个短幅(仅20-30个字眼!)来代表这一形象的持有人。 你在你工作的背后这样做,并照图像储存插图。
这方面的一个例子是:
import package:flutter/material.dart ;
import package:flutter_blurhash/flutter_blurhash.dart ;
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: Flutter Demo ,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const BlurHashApp(),
);
}
}
class BlurHashApp extends StatelessWidget {
const BlurHashApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) => MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text("BlurHash")),
body: const SizedBox.expand(
child: Center(
child: AspectRatio(
aspectRatio: 1.6,
child: BlurHash(
// hash was generated when you upload the image and returned along with image url by backend
hash: "LKN]Rv%2Tw=w]~RBVZRi};RPxuwH",
image: "https://blurha.sh/ea9e499f8080ce9956a8.jpg",
),
),
),
),
),
);
}
当你上载图像时,便会产生散射。
How? There are several implementation:
For example with python:
详细情况: