搜尋分類、套件與程式碼儲存庫

flutter_image_filters 封面
套件詳情v0.0.32

flutter_image_filters

基於 OpenGL(SPIR-V) 片段著色器的影像濾鏡,附帶實用的預覽小工具

AndroidiOSWebmacOS
近 30 天下載
5400
喜歡數
82
Pub 分數
140

安裝套件

flutter pub add flutter_image_filters

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個使用 OpenGL (SPIR-V) 片段著色器應用影像濾鏡的 Flutter 套件,可實現高效率的視覺效果。它包含預覽元件,可即時視覺化濾鏡結果,非常適合需要動態影像處理的應用程式。此套件支援多個平台,包括 Android、iOS、Web 和 macOS,確保廣泛的相容性。開發者可整合自訂著色器或使用內建濾鏡來實現模糊、亮度、對比度等效果。設計講求效率與易用性,適用於照片編輯工具、創意應用,以及任何需要低負載即時影像處理的應用。

適用情境

  • 即時照片編輯
  • 創意應用開發
  • 圖像增強工具
  • 多媒體應用中的視覺效果
  • 預覽應用濾鏡效果之前

主要特色

  • 基於 OpenGL 的片段著色器
  • 即時預覽小工具
  • 跨平台支援(Android、iOS、Web、macOS)
  • 高性能渲染
  • 支援自訂和內建過濾器

適合對象

  • 開發照片編輯應用的開發者
  • 創意工具創作者
  • 需要即時影像處理的應用程式
  • 面向多個平台的Flutter開發者
  • 想要高效著色器圖像效果的用戶

使用建議

  • 需要理解片段著色器
  • 在低階設備上可能具有更高的GPU使用率
  • 僅限影像過濾(非一般圖形)
  • 最適合靜態或影片幀,不適合動畫
  • 特定於平台的著色器編譯可能需要測試

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Pub codecov build Star on Github License: MIT

A flutter package for iOS and Android for applying OpenGL filters to image.

Usage

How to generate and use a bunch of filters
How to add custom filters
Export processed image
final texture = await TextureSource.fromAsset('demo.jpeg');
final configuration = BrightnessShaderConfiguration();
configuration.brightness = 0.5;
final image = await configuration.export(texture, texture.size);
Pipeline export

In case you see performance issues, look on how to generate and use bunch of filters

final texture = await TextureSource.fromAsset('demo.jpeg');
final brConfig = BrightnessShaderConfiguration();
brConfig.brightness = 0.5;

final stConfig = SaturationShaderConfiguration();
stConfig.saturation = 0.5;

final configuration = GroupShaderConfiguration();
configuration.add(brConfig);
configuration.add(stConfig);
final result = await configuration.export(texture, texture.size);
LookupTable sample

LUT

final texture = await TextureSource.fromAsset('demo.jpeg');
final configuration = SquareLookupTableShaderConfiguration();
await configuration.setLutAsset('lookup_amatorka.png');
final image = await configuration.export(texture, texture.size);
LookupTable HALD sample

LUT

final texture = await TextureSource.fromAsset('demo.jpeg');
final configuration = HALDLookupTableShaderConfiguration();
await configuration.setLutAsset('lookup_hald.png');
final image = await configuration.export(texture, texture.size);
ImageShaderPreview example
import 'package:flutter_image_filters/flutter_image_filters.dart';

class PreviewPage extends StatefulWidget {
  const PreviewPage({Key? key}) : super(key: key);

  @override
  State<PreviewPage> createState() => _PreviewPageState();
}

class _PreviewPageState extends State<PreviewPage> {
  late TextureSource texture;
  late BrightnessShaderConfiguration configuration;
  bool textureLoaded = false;

  @override
  void initState() {
    super.initState();
    configuration = BrightnessShaderConfiguration();
    configuration.brightness = 0.5;
    TextureSource.fromAsset('demo.jpeg')
        .then((value) => texture = value)
        .whenComplete(
          () => setState(() {
            textureLoaded = true;
          }),
        );
  }

  @override
  Widget build(BuildContext context) {
    return textureLoaded
        ? ImageShaderPreview(
            texture: texture,
            configuration: configuration,
          )
        : const Offstage();
  }
}
PipelineImageShaderPreview example
class PreviewPage extends StatefulWidget {
  const PreviewPage({Key? key}) : super(key: key);

  @override
  State<PreviewPage> createState() => _PreviewPageState();
}

class _PreviewPageState extends State<PreviewPage> {
  late TextureSource texture;
  late GroupShaderConfiguration configuration;
  bool textureLoaded = false;

  @override
  void initState() {
    super.initState();
    configuration = GroupShaderConfiguration();
    configuration.add(BrightnessShaderConfiguration()..brightness = 0.5);
    configuration.add(SaturationShaderConfiguration()..saturation = 0.5);
    TextureSource.fromAsset('demo.jpeg')
        .then((value) => texture = value)
        .whenComplete(
          () => setState(() {
        textureLoaded = true;
      }),
    );
  }

  @override
  Widget build(BuildContext context) {
    return textureLoaded
        ? PipelineImageShaderPreview(
      texture: texture,
      configuration: configuration,
    )
        : const Offstage();
  }
}
Divided preview sample
import 'package:before_after_image_slider_nullsafty/before_after_image_slider_nullsafty.dart';
import 'package:flutter_image_filters/flutter_image_filters.dart';

class PreviewPage extends StatefulWidget {
  const PreviewPage({Key? key}) : super(key: key);

  @override
  State<PreviewPage> createState() => _PreviewPageState();
}

class _PreviewPageState extends State<PreviewPage> {
  late TextureSource texture;
  late BrightnessShaderConfiguration configuration;
  bool textureLoaded = false;

  @override
  void initState() {
    super.initState();
    configuration = BrightnessShaderConfiguration();
    configuration.brightness = 0.5;
    TextureSource.fromAsset('demo.jpeg')
        .then((value) => texture = value)
        .whenComplete(
          () => setState(() {
            textureLoaded = true;
          }),
        );
  }

  @override
  Widget build(BuildContext context) {
    return textureLoaded
        ? BeforeAfter(
            thumbRadius: 0.0,
            thumbColor: Colors.transparent,
            beforeImage: ImageShaderPreview(
              texture: texture,
              configuration: NoneShaderConfiguration(),
            ),
            afterImage: ImageShaderPreview(
              texture: texture,
              configuration: configuration,
            ),
          )
        : const Offstage();
  }
}
Export & save processed image
import 'package:image/image.dart' as img;
import 'package:path_provider/path_provider.dart';



final texture = await TextureSource.fromAsset('demo.jpeg');
final configuration = BrightnessShaderConfiguration();
configuration.brightness = 0.5;
final image = await configuration.export(texture, texture.size);

final directory = await getTemporaryDirectory();
final output =
File('${directory.path}/result.jpeg');
final bytes = await image.toByteData();
final persistedImage = img.Image.fromBytes(
  image.width,
  image.height,
  bytes!.buffer.asUint8List(),
);
img.JpegEncoder encoder = img.JpegEncoder();
final data = encoder.encodeImage(persistedImage);
await output.writeAsBytes(data);

Additional information

Support status of GPUImage for iOS and GPUImage for Android shaders
Status Name
:white_check_mark: Brightness
:white_check_mark: Bulge Distortion
:white_check_mark: CGA Colorspace
:white_check_mark: Color Invert
:white_check_mark: Color Matrix
:white_check_mark: Contrast
:white_check_mark: Crosshatch
:white_check_mark: Exposure
:white_check_mark: False Color
:white_check_mark: Gamma
:white_check_mark: Glass Sphere
:white_check_mark: Grayscale
:white_check_mark: Halftone
:white_check_mark: Haze
:white_check_mark: Highlight Shadow
:white_check_mark: Hue
:white_check_mark: Lookup Table
:white_check_mark: Luminance
:white_check_mark: Luminance Threshold
:white_check_mark: Monochrome
:white_check_mark: Opacity
:white_check_mark: Pixelation
:white_check_mark: Posterize
:white_check_mark: RGB
:white_check_mark: Saturation
:white_check_mark: Solarize
:white_check_mark: Swirl
:white_check_mark: Vibrance
:white_check_mark: Vignette
:white_check_mark: White Balance
:white_check_mark: Zoom Blur
Sample results

Brightness Bulge Distortion CGA Colorspace Color Invert Color Matrix Contrast Crosshatch Exposure False Color Gamma Grayscale Halftone Haze Highlight Shadow Hue Square Lookup Table Luminance Threshold Luminance Monochrome Opacity Pixelation Posterize RGB Saturation Solarize Swirl Vibrance Vignette White Balance Zoom Blur

Examples

Maintainers

所屬分類

依賴

依賴清單 5 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。