I'm new to java and android development. I'm developing an application with a camera view in frameLayout window. My application is designed to be in portrait orientation but the window is in landscape < as shown in picture>. As u r familiar that default camera view is in landscape so I execute camera.setDisplayOrientation (90); to rotate it.
My issue is when image is rotated in portrait view under a landscape window it become distorted (Pinched). can any1 help me resolving this issue, can any1 provide me a solution to trim borders to achieve required ratio.
!Im a new user to stackoverflow so m not allowed to upload an image other wise I can show u.
___________________________________________
|____________Notification bar_______________|
| |
| My Application |
|___________________________________________|
| |
| |
| |
| |
| |
| |
| |
| camera View |
| ____________________ |
| | | |
| | | |
| | | |
| | | |
| | | |
| |____________________| |
| |
| |
| |
| |
| |
| |
| |
| |
|___________________________________________|
Code:
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height)
{
if(preview_running){
camera.stopPreview();
preview_running = false;
}
Camera.Parameters parameters = camera.getParameters();
List<Camera.Size> sizes = parameters.getSupportedPreviewSizes();
int mFrameWidth = width;
int mFrameHeight = height;
{
double minDiff = Double.MAX_VALUE;
for (Camera.Size size : sizes)
{
if (Math.abs(size.height - height) < minDiff)
{
mFrameWidth = size.width;
mFrameHeight = size.height;
minDiff = Math.abs(size.height - height);
}
}
}
if( (width*height) != 0){
parameters.setPreviewSize(mFrameHeight, mFrameWidth);
System.out.println("TEST 1");
}
camera.setDisplayOrientation(90);
camera.setParameters(parameters);
camera.startPreview();
preview_running = true;
}
I'm new to java and android development. I'm developing an application with a camera view in frameLayout window. My application is designed to be in portrait orientation but the window is in landscape < as shown in picture>. As u r familiar that default camera view is in landscape so I execute camera.setDisplayOrientation (90); to rotate it.
My issue is when image is rotated in portrait view under a landscape window it become distorted (Pinched). can any1 help me resolving this issue, can any1 provide me a solution to trim borders to achieve required ratio.
!Im a new user to stackoverflow so m not allowed to upload an image other wise I can show u.
___________________________________________
|____________Notification bar_______________|
| |
| My Application |
|___________________________________________|
| |
| |
| |
| |
| |
| |
| |
| camera View |
| ____________________ |
| | | |
| | | |
| | | |
| | | |
| | | |
| |____________________| |
| |
| |
| |
| |
| |
| |
| |
| |
|___________________________________________|
Code:
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height)
{
if(preview_running){
camera.stopPreview();
preview_running = false;
}
Camera.Parameters parameters = camera.getParameters();
List<Camera.Size> sizes = parameters.getSupportedPreviewSizes();
int mFrameWidth = width;
int mFrameHeight = height;
{
double minDiff = Double.MAX_VALUE;
for (Camera.Size size : sizes)
{
if (Math.abs(size.height - height) < minDiff)
{
mFrameWidth = size.width;
mFrameHeight = size.height;
minDiff = Math.abs(size.height - height);
}
}
}
if( (width*height) != 0){
parameters.setPreviewSize(mFrameHeight, mFrameWidth);
System.out.println("TEST 1");
}
camera.setDisplayOrientation(90);
camera.setParameters(parameters);
camera.startPreview();
preview_running = true;
}
0 commentaires:
Enregistrer un commentaire