uCrop icon indicating copy to clipboard operation
uCrop copied to clipboard

Support for Transparent images

Open sur950 opened this issue 5 years ago • 8 comments

Hi,

My image is transparent black logo and crop tool is adding black colour as default in background and after cropping, I see complete black screen and I would be very happy if you can add support for transparent images.

Thank you.

sur950 avatar Feb 14 '20 04:02 sur950

May be you is not calling

UCrop.Options configInstance = new UCrop.Options();
configInstance.setCompressionFormat(Bitmap.CompressFormat.PNG)

... before start UCropActivity. You can do this building a UCrop.Options instances and pass it on

UCrop.of(from, cropTo).withOptions(configInstance);

yenderlobo10 avatar Apr 07 '20 22:04 yenderlobo10

I will try that and will let you know.

sur950 avatar Apr 15 '20 09:04 sur950

yenderlobo10, the code you suggested is working perfectly, thank you. I tried it on real device moto E-4-plus Android KitKat. :)

gurpreet433 avatar May 07 '20 20:05 gurpreet433

yenderlobo10 but I don't know where it is documented though?

gurpreet433 avatar May 07 '20 20:05 gurpreet433

One more thing, it is working fine but if I have a completely black transparent png file then due to the background of the same colour it is not visible, so maybe that is the issue.

gurpreet433 avatar May 07 '20 22:05 gurpreet433

yenderlobo10 but I don't know where it is documented though? imagen ... Maybe the documentation it's not specific enough. I had to snoop around in the source code of the library and the examples, to find out why it didn't work.

yenderlobo10 avatar May 07 '20 22:05 yenderlobo10

One more thing, it is working fine but if I have a completely black transparent png file then due to the background of the same colour it is not visible, so maybe that is the issue.

I tested it on rooted Huawei P8 Lite, it worked with all the PNG's including your example. I advise you to check the examples in the library.

yenderlobo10 avatar May 07 '20 22:05 yenderlobo10

One more thing, it is working fine but if I have a completely black transparent png file then due to the background of the same colour it is not visible, so maybe that is the issue.

This is what the exact problem is and the issue is also pointed to the same. I tried Mi5, OnePlus5 with a black transparent image but as the background of the activity area is also black it is hard to find where exactly the image is and what we are cropping.

If you can make it distinguishable that will be really a cool thing to use. (For white transparent images it works fine as the activity background is black but the issue is only for black transparent images).

Thank you.

sur950 avatar May 08 '20 08:05 sur950