カテゴリー・パッケージ・リポジトリを検索

パッケージ詳細v1.2.1

blurhash_dart

BlurHashアルゴリズムの純粋なDart実装。このパッケージにはエンコーダーとデコーダー、およびいくつかのユーティリティ拡張機能が含まれています。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
11.3万
いいね数
135
Pub ポイント
160

パッケージをインストール

flutter pub add blurhash_dart

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

BlurHash Dart は、BlurHash アルゴリズムの純粋な Dart 実装であり、コンパクトな画像プレースホルダーの効率的な生成とデコードを可能にします。Flutter アプリケーションへのスムーズな統合を可能にするエンコーダーおよびデコーダー機能と有用なユーティリティ拡張を提供しています。ロード中に低帯域幅の画像プレビューを表示するのに最適で、Android、iOS、Web、macOS、Windows、Linux などの主要プラットフォームをすべてサポートしています。このパッケージは軽量で、外部依存関係なしにパフォーマンスを最適化するために設計されています。

用途

  • 読み込み中に画像プレースホルダを生成する
  • 大きな画像の低解像度プレビューを作成する
  • プレースホルダービジュアルによるアプリパフォーマンスの認識向上
  • 画像サムネイルにぼかし効果を統合する
  • ネットワーク負荷の高いアプリケーションでの画像読み込みの最適化

主な機能

  • 純粋なDart実装
  • エンコーダーとデコーダーが含まれています
  • 使いやすさのためのユーティリティ拡張
  • クロスプラットフォーム互換性
  • 軽量で高速
  • ネイティブな依存関係なし

適している対象

  • 画像のプレースホルダーが必要なFlutter開発者
  • ネットワーク状態が遅いまたは変動するアプリ
  • パフォーマンス重視のUI実装
  • プラットフォーム固有のコードを避ける開発者
  • 最小限のサードパーティライブラリが必要なプロジェクト

注意事項

  • 高精細な画像表現には適していません
  • BlurHash の概念を理解する必要があります
  • プレースホルダの使用事例に限定
  • 高度な画像処理機能をサポートしない可能性があります
  • 実際の画像の置き換えではなく、視覚的な強化として最適に使用されます

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

BlurHash Dart

A pure dart implementation of BlurHash. Supports both encoding and decoding. Runs on every supported Dart platform. See the BlurHash website or GitHub repository for more information.

The encoder of this dart implementation produces slightly different hashes than the TypeScript implementation but matches the official C and Python implementation. In practice this should not be relevant.

Basic usage

Decoding a BlurHash
import 'package:blurhash_dart/blurhash_dart.dart';
import 'package:image/image.dart' as img;

const hash = 'LEHV6nWB2yk8pyo0adR*.7kCMdnj';
BlurHash blurHash = BlurHash.decode(hash);
img.Image image = blurHash.toImage(35, 20);

// Display image...
Note: Usage with Flutter

Flutter does not expect raw bytes for its Image.memory widget, but fully encoded images with their corresponding headers (e.g. bitmap, jpg, png). The easiest way to accomplish this, is to use, for example, encodeJpg from package:image:

Widget build(BuildContext context) {
  final image = BlurHash.decode('LEHV6nWB2yk8pyo0adR*.7kCMdnj').toImage(35, 20);
  return Image.memory(Uint8List.fromList(encodeJpg(image)));
}

It is recommended to cache the resulting image in a stateful widget, such that it does not need to be recomputed on every build call.

Encoding an Image
import 'dart:io';

import 'package:blurhash_dart/blurhash_dart.dart';
import 'package:image/image.dart' as img;

final data = File('path/to/image.png').readAsBytesSync();
final image = img.decodeImage(data.toList());
final blurHash = BlurHash.encode(image!, numCompX: 4, numCompY: 3);

print(blurHash.hash);
Extension Methods

Additional extension methods to compute, for example color averages, are available when importing package:blurhash_dart/blurhash_extensions.dart. See example for basic usage.

カテゴリー

依存関係

依存関係一覧 1 件

ソースリポジトリ

このパッケージを使用しているプロジェクト