Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Crop images #1136

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

feat: Crop images #1136

wants to merge 8 commits into from

Conversation

QubaB
Copy link
Contributor

@QubaB QubaB commented Feb 23, 2024

Implemented image cropping (cliping)

Works only for png and svg. Pdf files are only background and are not cropped.

How it works:

  • 1st tap on image shows handles to resize image (as already implemented)
  • 2nd tap changes handles to squares and their movement sets part of image which is displayed.
  • 3rd tap (or tap outside image) removes handles and only selected part of image is displayed.
  • Cropped image can be resized again and crop rectangle can be changed.

Putting image as background shows only selected area on background.

canvas_image.dart has been greatly reworked.

srcRect of image gives part of image to be drawn. Original size of image is stored in naturalSize
dstFullRect is newly introduced as image property, which determines the area on the canvas that corresponds to the entire image.
ClipRect is used to crop the image in canvas_image.dart.

I tested image cropping on png and svg images. It works also for when image is set as background.

Closes #1088 (I hope)

Example: ImageCrop.webm

I would like to ask for thorough testing and comments on implementation or complete rewrite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Image croping (clipping)
1 participant