boxme / SquareCamera

Android Camera Library For Square Photo Taking
MIT License
569 stars 189 forks source link

Stretched Preview for 3:4 aspect ratio #32

Open rohanmahale opened 8 years ago

rohanmahale commented 8 years ago

I have used your SurfaceView Class in my camera implementation. The 3:4 aspect ratio works great in most cases. However in some phones(samsung e5 for eg), the preview is getting stretched,is there a fix for this?

rohanmahale commented 8 years ago

Hey @philipgiuliani. Could you help me out? I am using the same preview class that is being used in the square camera lib. However in a samsung e5, the front camera preview is getting stretched. How do I make sure that the preview works on all devices without it getting stretched.

philipgiuliani commented 8 years ago

Hi. You are on the current version of the library, or? I remember some streching issues here: https://github.com/boxme/SquareCamera/issues/8 but they seem to be solved. I am not using this library directly, have modified a lot in my projects. If you want i can send you my code. In my project its working perfect on a S5 with front camera! https://play.google.com/store/apps/details?id=com.keepinmind.lifeshot

rohanmahale commented 8 years ago

Yeah I just used the preview class from the library here. Could you please share your code? I have seen that it stretches in the front cam of a samsung e5(not sure if it stretches on s5)

philipgiuliani commented 8 years ago

Could you test if you get the problems in the lifeshot app? To reach the camera, just create a lifeshot (bottom right button, 2 times), set it to "Just now" and it should start. You will need a friend to do this. You can add me: "Philip Giuliani" (through the search).

rohanmahale commented 8 years ago

The problem is I do not have access to that device. That person with the device sent me a screen shot and he is not available for most of the day.

philipgiuliani commented 8 years ago

Oh that's bad :( Im not sure if it works with my code. I modified a lot and it won't be compatible with the current version of the library.

I pasted everything about the processing, rotating ect. Try to update your ProcessImage Async task to be like this one. It will also speed-up the processing!

// Code removed

rohanmahale commented 8 years ago

But isnt the relevant class in this case the Camera Preview Class(Surfaceview)? I'm not having issues with the actual image stretching I think. It is the camera preview which is appearing stretched on the e5.

In my UI I have a fixed panel at the bottom(some 100dp or 200 dp or so), and the camera preview fills the rest of the screen above it. This works on quite a few devices. The only complaint up until now was from the guy with the e5. The camera preview width and height is set to matchParent and is above the bottom controls panel.

philipgiuliani commented 8 years ago

Ah oh the camera preview... Than i understood it wrong. So you have fixed sizes? You will have to calculate the height of the covers, they are different for every device of course...

My cover size code: // Code removed

philipgiuliani commented 8 years ago

I have added the .requestLayout() because it wasnt working somewhere. I dont remember...

rohanmahale commented 8 years ago

Nope... I mean my bottom controls bar is of a fixed size. The rest of the screen above it has to be the camera preview.