Photofilters 是一个 Flutter 包,可让开发者在其应用中对图像应用各种视觉滤镜。它支持内置滤镜和自定义滤镜创建,允许用户设计独特的子滤镜。该包非常适合移动和桌面应用程序中的照片编辑功能。它支持 Android、iOS、macOS、Windows 和 Linux,提供跨平台一致性。其直观的 API 简化了现有项目的集成。
适合场景
照片应用中的图像编辑
为用户上传的照片添加创意效果
构建可定制的照片滤镜画廊
增强社交媒体应用中的照片分享功能
创建艺术图像转换工具
主要特点
对内置和自定义筛选器的支持
创建子筛选器的能力
跨平台兼容性
与 Flutter 的轻松集成
轻量且高性能的渲染
适合对象
开发照片编辑应用的开发者
创意工具创作者
跨平台多媒体应用
寻求视觉增强的UI设计师
需要实时图像过滤的应用程序
使用建议
需要了解图像处理基础知识
自定义过滤器的创建可能需要反复试验
性能在低端设备上可能有所不同
除了基本示例外,文档有限
可能需要额外的资产管理来处理复杂过滤器
原始 README
以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。
Photo Filters package for flutter
A flutter package for iOS and Android for applying filter to an image. A set of preset filters are also available. You can create your own filters too.
There are two types of filters. ImageFilter and ColorFilter.
Image Filter
Image filter applies its subfilters directly to the whole image one by one. It is computationally expensive since the complexity & time increases as the number of subfilters increases.
You can create your own custom image filter as like this:
Color filter applies its subfilters to each pixel one by one. It is computationally less expensive than the ImageFilter. It will loop through the image pixels only once irrespective of the number of subfilters.
You can create your own custom color filter as like this:
import'package:photofilters/filters/color_filters.dart';
var customColorFilter = newColorFilter(name: "Custom Color Filter");
customColorFilter.addSubFilter(SaturationSubFilter(0.5));
customColorFilter
.addSubFilters([BrightnessSubFilter(0.5), HueRotationSubFilter(30)]);
You can inherit the ColorFilter class too
classMyColorFilterextendsColorFilter{
MyColorFilter() : super(name: "My Custom Color Filter") {
this.addSubFilter(BrightnessSubFilter(0.8));
this.addSubFilter(HueRotationSubFilter(30));
}
}
Sub filters
There are two types of subfilters. One can be added to the ColorFilter and the other can be added to the ImageFilter. You can inherit ColorSubFilter class to implement the former and you can use the ImageSubFilter mixin to implement the latter. You can create a same subfilter that can be used for both Image and Color Filters. The BrightnessSubFilter is an example of this.
classBrightnessSubFilterextendsColorSubFilterwithImageSubFilter{
finalnum brightness;
BrightnessSubFilter(this.brightness);
///Apply the [BrightnessSubFilter] to an Image.@overridevoidapply(Uint8List pixels, int width, int height) =>
image_filter_utils.brightness(pixels, brightness);
///Apply the [BrightnessSubFilter] to a color.@override
RGBA applyFilter(RGBA color) =>
color_filter_utils.brightness(color, brightness);
}
Getting Started
For help getting started with Flutter, view our online documentation.
For help on editing package code, view the documentation.