androidandroid-cameracommonsware-cwaccwac-camera

CWAC Camera - What's the best way to customize the ImageCleanupTask?


I'm using the cwac-camera library to take photos with a custom in-app camera.

I'm overriding adjustPreviewParameters in SimpleCameraHost and am setting the JPEG quality.

@Override
public Parameters adjustPreviewParameters(Parameters parameters) {
    super.adjustPreviewParameters(parameters);
    parameters.setJpegQuality(80);
    return (parameters);
}

Unfortunately, as per this question, the setJpegQuality method doesn't work on some devices (e.g. the S3).

I can see that the cwac-camera ImageCleanupTask always saves the manipulated image at 100% JPEG quality.

What's the best way to customize the ImageCleanupTask?

Should I expose a setJpegQuality method in PictureTransaction? Or do we want a more versatile solution (like allowing the ImageCleanupTask to be injected)?


Solution

  • I can see that the cwac-camera ImageCleanupTask always saves the manipulated image at 100% JPEG quality.

    Ideally, that would be configurable. There are lots of things the library would ideally do. :-)

    What's the best way to customize the ImageCleanupTask?

    If you mean "how would one get the JPEG percentage in there?", augment PictureTransaction.

    Should I expose a setJpegQuality method in PictureTransaction?

    I would do jpegQuality(), as PictureTransaction uses the builder/fluent API pattern.

    Note that with this change, you would want to remove parameters.setJpegQuality(80); from your existing code. Otherwise, the image will be degraded twice, once on capture (for devices that support it) and once when the image is written to disk, and that's probably not what you want.