パッケージ、リポジトリ、アプリカテゴリを検索

GitHub リポジトリberkayceylan/bc_image_editor

bc_image_editor

画像編集用のFlutterパッケージ。

bc_image_editor のプロジェクト画像
スター
11
フォーク
1
最終プッシュ(UTC)
2022/08/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

MIT

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

Berkay CEYLAN GitHub avatar
GitHub 作者

Berkay CEYLAN ↗

Backend supported frontend developer. Recently, Flutter and Django and some web frontend :)

言語Dart

使用している依存関係

依存関係一覧 5 件

プロジェクトに合うリポジトリを選ぶには?

用途で絞り込み、開発状況を比較し、採用前に元のリポジトリで要件を確認しましょう。

  1. 名前・作者・説明で検索し、技術トピックで絞り込みます。
  2. スター、フォーク、最近のプッシュを比較します。スターは関心の目安であり、品質の保証ではありません。
  3. 利用前に GitHub で README、ライセンス、Issues を確認します。

情報源と管理

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗