Search in sources :

Example 1 with SaveImage

use of com.android.gallery3d.filtershow.tools.SaveImage in project android_packages_apps_Gallery2 by LineageOS.

the class ImageSavingTask method doInBackground.

public Result doInBackground(Request message) {
    SaveRequest request = (SaveRequest) message;
    Uri sourceUri = request.sourceUri;
    Uri selectedUri = request.selectedUri;
    File destinationFile = request.destinationFile;
    Bitmap previewImage = request.previewImage;
    ImagePreset preset = request.preset;
    boolean flatten = request.flatten;
    final boolean exit = request.exit;
    // We create a small bitmap showing the result that we can
    // give to the notification
    UpdateBitmap updateBitmap = new UpdateBitmap();
    updateBitmap.bitmap = createNotificationBitmap(previewImage, sourceUri, preset);
    postUpdate(updateBitmap);
    SaveImage saveImage = new SaveImage(mProcessingService, sourceUri, selectedUri, destinationFile, previewImage, new SaveImage.Callback() {

        @Override
        public void onPreviewSaved(Uri uri) {
            UpdatePreviewSaved previewSaved = new UpdatePreviewSaved();
            previewSaved.uri = uri;
            previewSaved.exit = exit;
            postUpdate(previewSaved);
        }

        @Override
        public void onProgress(int max, int current) {
            UpdateProgress updateProgress = new UpdateProgress();
            updateProgress.max = max;
            updateProgress.current = current;
            postUpdate(updateProgress);
        }
    });
    Uri uri = saveImage.processAndSaveImage(preset, flatten, request.quality, request.sizeFactor, request.exit);
    if (uri != null) {
        FilterRepresentation rep = preset.getFilterRepresentation(0);
        if (rep != null) {
            Log.d(GalleryActivity.QSST, "edited image saved successfully " + rep.getName());
        }
    }
    URIResult result = new URIResult();
    result.uri = uri;
    result.exit = request.exit;
    result.requestId = request.requsetId;
    return result;
}
Also used : FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation) SaveImage(com.android.gallery3d.filtershow.tools.SaveImage) Uri(android.net.Uri) Bitmap(android.graphics.Bitmap) File(java.io.File)

Aggregations

Bitmap (android.graphics.Bitmap)1 Uri (android.net.Uri)1 FilterRepresentation (com.android.gallery3d.filtershow.filters.FilterRepresentation)1 SaveImage (com.android.gallery3d.filtershow.tools.SaveImage)1 File (java.io.File)1