RedApparat / Fotoapparat

Making Camera for Android more friendly. 📸
Apache License 2.0
3.82k stars 405 forks source link

Custom SizeSelector is not working on some devices like Xiaomi MI5 #142

Closed zagulakamil closed 6 years ago

zagulakamil commented 6 years ago

What are you trying to achieve or the steps to reproduce?

I created my own SizeSelector for photoSize and previewSize which looks like Collections.max(items, CompareSizesByArea()).flip() to makes photo in 3:4 aspect ration instead of 4:3. On some devices like Nexus 5 it is pretty ok and everything works fine, but on Xiaomi Mi5 my custom SizeSelector is omitted. The output photoSize is the smallest one possible. When i set the default biggestSize() provided by library the image is always in biggest possible resolution.

How did you initialize FA?

fotoapparat = Fotoapparat
                .with(this.context)
                .into(binding.camera)
                .previewSize { items -> Collections.max(items, CompareSizesByArea()).flip() }
                .previewScaleType(ScaleType.CENTER_CROP)
                .photoSize { items -> Collections.max(items, CompareSizesByArea()).flip() }
                .flash(Selectors.firstAvailable(
                        FlashSelectors.autoFlash(),
                        FlashSelectors.off()
                ))
                .lensPosition(back())
                .focusMode(Selectors.firstAvailable(
                        continuousFocus(),
                        autoFocus(),
                        fixed()
                ))
                .build()

What was the result you received?

The result on Xiaomi is preview size equal to the biggest possible resolution and smallest possible photo size.

What did you expect?

I'm expecting the biggest possible resolution of photo but fliped one. For example SizeSelector.biggestSize() returns Size of 1920 width and 1080 height, but i want Size of 1920 height and 1080 width.

Context:

Diolor commented 6 years ago

The items on your left hand side of the lambda are the available sizes. When you flip the size you mutate the selected from the max function item but that doesn't mean that the device will support it -> since it's not in the original items list.

Doesn't matter if you want a 1080x1920 instead of 1920x1080 picture, the hardware might not be able to support it. This might work for small sizes but definitely not the biggest one.