Jon Miranda | 16ea1b1 | 2017-12-12 14:52:48 -0800 | [diff] [blame] | 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; |
Jon Miranda | 16ea1b1 | 2017-12-12 14:52:48 -0800 | [diff] [blame] | 20 | |
| 21 | import com.android.wallpaper.asset.Asset; |
| 22 | |
Sunny Goyal | 8600a3f | 2018-08-15 12:48:01 -0700 | [diff] [blame^] | 23 | import androidx.annotation.Nullable; |
| 24 | |
Jon Miranda | 16ea1b1 | 2017-12-12 14:52:48 -0800 | [diff] [blame] | 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 | */ |
| 34 | void cropAndScaleBitmap(Asset asset, float scale, Rect cropRect, Callback callback); |
| 35 | |
| 36 | /** |
| 37 | * Interface for receiving the output bitmap of crop operations. |
| 38 | */ |
| 39 | interface Callback { |
| 40 | void onBitmapCropped(Bitmap croppedBitmap); |
| 41 | |
| 42 | /** |
| 43 | * Called on an error during the crop. If a Throwable was caught along the way, it is passed |
| 44 | * here. |
| 45 | */ |
| 46 | void onError(@Nullable Throwable e); |
| 47 | } |
| 48 | } |