bc_image_editor
用於影像編輯的 Flutter 套件。
- 星標
- 11
- 分支
- 1
- 最近推送(UTC)
- 2022年8月11日
- 專案狀態
- 未封存
原始 README
以下為英文專案原文快照,最新內容請造訪 GitHub。
BC Image Editor
You can edit image using this package and also you can create flex preview image by setting foreground to null. For now, you can use only asset files.
https://pub.dev/packages/bc_image_editor
Features
- Background and Foreground(optional) image
- Resize images
- Set x,y position them
- 3D rotate image image on x, y axis (Foreground only)
- 2D rotate foreground image
- Scale for detail view
- Use on device files or asset files
- Edit foreground image with gesture detector moves.
- Size and position.
- 3D rotate Horizontal and Vertical
- 2D rotate
- View mode (Scale)
Getting started
Import:
import 'package:bc_image_editor/bc_image_editor.dart';
Using:
BcImageEditor(
frontImage: "image/path",
bgImage: "image/path",
frontWidth: 200,
frontHeight: 300,
bgWidth: 300,
bgHeight: 200, //If one of variable of width and height not setted or set to null, the other one will auto scale
frontLeft: 10,
frontTop: 10,
bgLeft: 10,
bgTop: 10,
frontBoxFit: BoxFit.fill,
bgBoxFit: BoxFit.fill,
rotateX: 0, //rotateX and y are on 3D axis
rotateY: 0,
rotate2D: 0,
),
Edit image with gesture detector
Import:
import 'package:bc_image_editor/edit_with_gesture.dart';
Using:
EditWithGesture(
frontImage: frontFilePath,
bgImage: bgFilePath,
editMode: EditMode.verticalRotate,
);
Gesture Editing Modes:
| Editing Mode | Function |
|---|---|
| size | Resize and change position image. |
| horizontalRotate | Rotate image horizontal on 3D axis. |
| verticalRotate | Rotate image vertical on 3D axis. |
| rotate2D | 2D rotation. |
| viewMode | Zoom image for detail things (it doesn't do any editing). |
| noEdit | Close the editing. |
Using from asset folder image
First initialize your path name:
String imagePath = "";
Then create a async function like below and use it in initState:
void initFiles() async {
File tempImg =
await getImageFileFromAssets("assets/image/path");
setState(() {
imagePath = tempImg.path;
});
}
Example
For example; you wanna edit image with gesture detector and use image from asset file.
Import edit_with_gesture file
import 'package:bc_image_editor/bc_image_editor.dart';
import 'package:bc_image_editor/edit_with_gesture.dart';
Create file paths as variables:
String frontFilePath = "", bgFilePath = "";
Create a async variable to get image files. And get images from asset with "getImageFileFromAssets" function. (If you want use device image you can write path directly).
void initFiles() async {
File frontTempFile =
await getImageFileFromAssets("assets/images/example-front.png");
File tempFileBg = await getImageFileFromAssets("assets/images/example-bg.jpg");
setState(() {
frontFilePath = frontTempFile.path;
bgFilePath = tempFileBg.path;
});
}
Use this function on initState:
@override
void initState() {
// TODO: implement initState
super.initState();
initFiles();
}
Use EditWithGesture widget:
EditWithGesture(
frontImage: frontFilePath,
bgImage: bgFilePath,
editMode: EditMode.verticalRotate,
);
Edit With Gesture Detector Examples:
EditMode.size
EditMode.horizontalRotate
EditMode.verticalRotate
EditMode.rotate2D
EditMode.viewMode
Full Code:
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:bc_image_editor/bc_image_editor.dart';
import 'package:bc_image_editor/edit_with_gesture.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
home: Scaffold(
appBar: AppBar(
title: const Text("Test"),
),
body: const Home(),
),
);
}
}
class Home extends StatefulWidget {
const Home({Key? key}) : super(key: key);
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
String frontFilePath = "", bgFilePath = "";
void initFiles() async {
File frontTempFile =
await getImageFileFromAssets("assets/images/char-2.png");
File tempFileBg = await getImageFileFromAssets("assets/images/bg-2.jpg");
setState(() {
frontFilePath = frontTempFile.path;
bgFilePath = tempFileBg.path;
});
}
@override
void initState() {
super.initState();
initFiles();
}
@override
Widget build(BuildContext context) {
return EditWithGesture(
frontImage: frontFilePath,
bgImage: bgFilePath,
editMode: EditMode.verticalRotate,
);
}
}
LICENSE
MIT License
使用的依賴
依賴清單 5 項
- flutter
{"sdk":"flutter"} - gesture_x_detector
^1.0.0 - path_provider
^2.0.9 - flutter_test開發依賴
{"sdk":"flutter"} - flutter_lints開發依賴
^1.0.0
如何選擇適合專案的儲存庫?
先依使用情境篩選,再比較專案活躍情況,最後到原始儲存庫確認使用要求。
- 透過儲存庫名稱、作者或描述搜尋,再依技術分類縮小範圍。
- 綜合星標、分支與最近推送比較專案;星標反映社群關注,不保證品質。
- 使用前在 GitHub 確認 README、授權條款與 Issues。
來源與維護
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗