burhanrashid52 / PhotoEditor

A Photo Editor library with simple, easy support for image editing using paints,text,filters,emoji and Sticker like stories.
MIT License
4.12k stars 989 forks source link

Using StickerView for stickers and emojis #234

Open msroid opened 4 years ago

msroid commented 4 years ago

Please use something like this for stickers and emojis. Right now it's hard to resize and rotate stickers and specially emojis and there is no option for flipping them.

lucianocheng commented 3 years ago

@msroid I'll check this out.

Looks like they use a cool trick to keep the "corner buttons" consistent size here, at the very least we could apply that.

lucianocheng commented 3 years ago

@burhanrashid52 could you assign this to me? Thanks.

lucianocheng commented 2 years ago

Specifically they use a function called convertDpToPixel to convert the handle to a fixed pixel size using the system screen's DPI measurement. Basically forcing the re-size of the handle to a fixed number of pixels for every redraw.

lucianocheng commented 2 years ago

Ok, I took a closer look at this.

android-StickerView (the repo linked in the first comment) uses a different method for scaling stickers than us:

Since android-StickerView sets the x and y values directly, they don't have a view tree where the image, handles, graphic frame, etc are all scaled. Since it's just the inner image that is scaled, the handles have the same scale "transformation matrix" per se, which means they don't need adjusting.

We could use this technique for ImageView types (stickers), but unfortunately, TextViews can't have FIT_XY set as ScaleType. So it wouldn't work for Text or Emoji. android-StickerView gets around this by changing the font / dp size of the text when scaling.

The android-StickerView technique is probably a superior solution, but it would require significant refactoring to use. Using the library directly probably isn't a good idea since hooking it into our callback system for other functionality would be difficult. The library also hasn't been updated in 5 years so I worry about long term maintenance.

Bottom Line: This is still a good idea, but it's not easy to implement. Will probably require one or two large refactorings (zoom and text / emoji frame logic) to implement. It's much more than just handle sizes.

[1] https://github.com/tonguetech/Android-StickerView/blob/master/src/main/java/com/knef/stickerview/StickerImageView.java#L48