blob: ca38d2eeb32fafe6946fbb836f1859e8f76f04af [file] [log] [blame]
Jon Miranda16ea1b12017-12-12 14:52:48 -08001/*
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 */
16package com.android.wallpaper.module;
17
18import android.graphics.Bitmap;
19import android.graphics.Rect;
Jon Miranda16ea1b12017-12-12 14:52:48 -080020
21import com.android.wallpaper.asset.Asset;
22
Sunny Goyal8600a3f2018-08-15 12:48:01 -070023import androidx.annotation.Nullable;
24
Jon Miranda16ea1b12017-12-12 14:52:48 -080025/**
26 * Interface for classes which perform crop operations on bitmaps.
27 */
28public 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}