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.14k stars 991 forks source link

How to scale source image to fit the space #528

Closed KhoaChau0594 closed 1 year ago

KhoaChau0594 commented 1 year ago

Hello everyone. I got a problem with scaling while using the library is the PhotoEditorView doesn't scale the image to fill all the screen width.

I am using Glide to load the image:

Glide.with(cont)
        .load(media)
        .into(binding.photoEditorView.source)

I have a 653x1024 PNG image, but it just renders half of the photo view

This is when previewing the image, and what I want the PhotoEditorView to display : Screenshot 2023-05-21 at 22 14 20

This is when editing the image Screenshot 2023-05-21 at 22 15 13

I've tried to change the scaleType to fitXY of the binding.photoEditorView.source, but it is still the same. If the scaleType is CENTER, the editor just shows the center of the image Screenshot 2023-05-21 at 22 23 19

Thanks for your help.

burhanrashid52 commented 1 year ago

Can you try to load this same image using glide on normal ImageView? Does it work correctly there ?

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 20 days with no activity. Remove stale label or comment or this will be closed in 4 days.

Harshal624 commented 1 year ago

Can you try to load this same image using glide on normal ImageView? Does it work correctly there ?

I'm having the same issue. I am not using Glide though, I am loading image using setImageURI(). I tried loading image on normal imageview, it scales up fine.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 20 days with no activity. Remove stale label or comment or this will be closed in 4 days.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stalled for 5 days with no activity.

aintiqaa-technologies commented 4 months ago

mPhotoEditorView.source.scaleType = ImageView.ScaleType.CENTER_CROP

fun loadImage(imgURL: Uri?, errorThumb: Int?, imgView: PhotoEditorView?,mMeasuredWidth:Int) { imgView?.source?.load(imgURL) { placeholder(errorThumb ?: 0) error(errorThumb ?: 0) memoryCachePolicy(CachePolicy.ENABLED) allowHardware(false) size(mMeasuredWidth) } }

This worked in my case I am using Coil to load Image