Q: Image quality is poor using custom camera I am using custom camera and working fine but the issue is image is saving with very low (poor) quality. To overcome with it , i have tried all suggestions and implementations. Like  ,
parameters.setJpegQuality(100);
parameters.setPictureFormat(ImageFormat.JPEG);

this is not working. After that i have used
List<Size> sizes = cameraParams.getSupportedPictureSizes();
Camera.Size size = sizes.get(0);
for(int i=0;i<sizes.size();i++)
{
 if(sizes.get(i).width > size.width)
 size = sizes.get(i);
}
cameraParams.setPictureSize(mPictureSize.width, mPictureSize.height);

This is also not working. Its saving with poor quality still. 
Note : Camera preview is showing proper with good quality but the issue is when saving captured image to sdcard folder.
Advanced help would be appreciated!! 

A: Finally my issue solved. 
Here I was setting parameters for camera preview before i was capturing the image
 public void takePicture() {
    mCamera.takePicture(new ShutterCallback() {
        @Override
        public void onShutter() {

        }
    }, new PictureCallback() {
        @Override
        public void onPictureTaken(byte[] data, Camera camera) {

        }
    }, new PictureCallback() {
        @Override
        public void onPictureTaken(final byte[] data, Camera camera) {

            data1 = data;
            if (mCamera != null) {
                mCamera.stopPreview();
            }
        }
    });
}

So before i called this function in my fragment i have set parameters before this method.
mPreview.setParams(params);// This was the mistake what i have done !
mPreview.takePicture();

finally solved after removing  mPreview.setParams(params);

A: I can show you methods for resetting preview size:
You should change your parameters of preview at Camera.
private void setImageSize() {
        Camera.Size size = CameraUtil.findClosetImageSize(mRxCamera.getNativeCamera(), PREFER_SIZE);
        mCamera.getNativeCamera().getParameters().setPictureSize(size.width, size.height);
        WIDTH = size.width;
        HEIGHT = size.height;
    }

and after You need to change layout sizes 
private void resetPreviewSize() {
        final boolean widthIsMax = mWidth > mHeight;
        final Camera.Size size = mCamera.getNativeCamera().getParameters().getPreviewSize();

        final RectF rectDisplay = new RectF();
        final RectF rectPreview = new RectF();

        rectDisplay.set(0, 0, mWidth, mHeight);

        final int width = widthIsMax ? size.width : size.height;
        final int height = widthIsMax ? size.height : size.width;
        rectPreview.set(0, 0, width, height);

        final Matrix matrix = new Matrix();
        matrix.setRectToRect(rectDisplay, rectPreview, Matrix.ScaleToFit.START);
        matrix.invert(matrix);
        matrix.mapRect(rectPreview);

        mCameraView.getLayoutParams().height = (int) (rectPreview.bottom);
        mCameraView.getLayoutParams().width = (int) (rectPreview.right);
        mCameraView.requestLayout();
    }

and if you need
public static Camera.Size findClosetImageSize(Camera camera, Point preferSize) {
    int preferX = preferSize.x;
    int preferY = preferSize.y;
    Camera.Parameters parameters = camera.getParameters();
    List<Camera.Size> allSupportSizes = parameters.getSupportedPictureSizes();
    Log.d(TAG, "all support Image size: " + dumpPreviewSizeList(allSupportSizes));
    int minDiff = Integer.MAX_VALUE;
    int index = 0;
    for (int i = 0; i < allSupportSizes.size(); i++) {
        Camera.Size size = allSupportSizes.get(i);
        int x = size.width;
        int y = size.height;

        int diff = Math.abs(x - preferX) + Math.abs(y - preferY);
        if (diff < minDiff) {
            minDiff = diff;
            index = i;
        }
    }
    return allSupportSizes.get(index);
}

