• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.wallpaper.module;
17 
18 import android.graphics.Bitmap;
19 import android.graphics.Rect;
20 
21 import androidx.annotation.Nullable;
22 
23 import com.android.wallpaper.asset.Asset;
24 
25 /**
26  * Interface for classes which perform crop operations on bitmaps.
27  */
28 public interface BitmapCropper {
29 
30     /**
31      * Crops and scales a bitmap per the given scale factor and crop area (at target scale) from the
32      * source asset.
33      */
cropAndScaleBitmap(Asset asset, float scale, Rect cropRect, boolean adjustForRtl, Callback callback)34     void cropAndScaleBitmap(Asset asset, float scale, Rect cropRect, boolean adjustForRtl,
35             Callback callback);
36 
37     /**
38      * Interface for receiving the output bitmap of crop operations.
39      */
40     interface Callback {
onBitmapCropped(Bitmap croppedBitmap)41         void onBitmapCropped(Bitmap croppedBitmap);
42 
43         /**
44          * Called on an error during the crop. If a Throwable was caught along the way, it is passed
45          * here.
46          */
onError(@ullable Throwable e)47         void onError(@Nullable Throwable e);
48     }
49 }
50