Bitmap은 Android 및 iOS에서 효율적인 이미지 조작을 위해 설계된 가볍고 고성능의 Dart 패키지입니다. 개발자가 픽셀 데이터를 직접 다룰 수 있게 하며, 스케일링, 자르기, 색상 조정과 같은 빠른 작업을 제공합니다. 실시간 이미지 처리 또는 최소한의 오버헤드가 필요한 앱에 적합하며, Flutter 프로젝트에 원활하게 통합됩니다. 단순함과 속도에 중점을 두어 이미지 필터링, 썸네일 생성, 사용자 정의 렌더링 등의 작업에 적합합니다. 최소한의 종속성과 명확한 API를 통해 성능을 희생하지 않고 멀티미디어 워크플로우를 간소화합니다.
사용 사례
실시간 이미지 필터링
미리보기 생성
이미지 자르기 및 크기 조정
사용자 지정 이미지 렌더링
기기 내 사진 편집
주요 기능
고속 픽셀 조작
최소 메모리 사용량
크로스 플랫폼 지원 (Android 및 iOS)
간단하고 직관적인 API
경량 종속성
적합한 대상
성능 중심의 이미지 처리
이미지 편집이 필요한 모바일 앱
최소 오버헤드를 원하는 개발자
기기 내 이미지 변환을 필요로 하는 앱
다양한 미디어 도구에 중점을 둔 플러터 프로젝트
고려 사항
기본 이미지 작업에 제한됨
고급 필터에 대한 내장 지원 없음
픽셀 수준 조작에 대한 이해가 필요합니다
복잡한 이미지 분석에 적합하지 않음
간단하고 빠른 변환에 가장 적합
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
Flutter Bitmap
A minimalist Flutter package to perform fast bitmaps operations.
The focus here is to provide a cool bitmap manipulation interface.
Bitmap uses the Dart FFI to perform operations such as contrast, brightness, saturation, and exposure.
For now, things like format encoding, EXIF and multi-frame images are not the concern of this package. If that is your need, check image.
Some of the algorithms here are heavily inspired by this awesome lib.
Why this exists?
I started to use dart image to create LetsPicture (cool app, check it out) but since the beginning, I've noticed that the performance was really bad.
Dart image has its own Image format, so between decoding, putting some transformations and then displaying the result on the app you had to convert the image two times (at least).
So this package is just this: We deal bitmaps (duh) and we focus only on Flutter use cases.
bitmap takes some advantages from Flutter:
Every image is decoded to RGBA32 by the framework trough ImageStreamListener, so we can rely on Flutter to do the decoding job;
Dart FFI: we are porting some of our functions to C (or C++) making it blazing fast.
With this package, you can easily take advantage of stuff like compute (Isolates) on only the manipulations you want to free the UI thread of heavy computation.
Flutter has a powerful ColorFilter class (that came from skia) which can be used to put some color corrections when painting stuff on canvas. You can use a matrix to correct color (Some matrix examples here).
Not every color transformation can be done through the matrix, though.
Basic usage
1. Image to Bitmap
Everything is around the Bitmap class. You can get an instance of that from any ImageProvider.
import'package:bitmap/bitmap.dart';
Bitmap bitmap = awaitBitmap.fromProvider(NetworkImage("http://pudim.com.br/pudim.jpg")); // Notice this is an async operation
The Bitmap class has also a helper function buildImage that uses Flutter's decodeImageFromList to build a dart:ui Image.
With an Image, you can paint it in a canvas (in a CustomPainter, for example).
You can also save the image as a .bmp file (get the file content with the .buildHeaded() method).
You can check also the image lib where you can save the image in several formats.
The capability of calling a c (or c++) function from dart can help us a lot in getter better performance times.
Isolates
Most of the manipulations on the bitmap take a long time to be completed. That's is because they have to iterate on every item of the bitmap.
A picture with a 400px width and height sizes will generate a list of 640000 integers. This is a heavy computation.
Those can be expensive. Sou you may use Isolates there to free the UI thread from all of this work.
Check the example app, where the transformations are applied through the compute function.
Important: it is noticed that the performance increases a lot when using release mode on your Flutter App