blob: e23cfdc9b04a62708a813f02e1828a0203d709f1 [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;
20import android.support.annotation.Nullable;
21
22import com.android.wallpaper.asset.Asset;
23
24/**
25 * Interface for classes which perform crop operations on bitmaps.
26 */
27public interface BitmapCropper {
28
29 /**
30 * Crops and scales a bitmap per the given scale factor and crop area (at target scale) from the
31 * source asset.
32 */
33 void cropAndScaleBitmap(Asset asset, float scale, Rect cropRect, Callback callback);
34
35 /**
36 * Interface for receiving the output bitmap of crop operations.
37 */
38 interface Callback {
39 void onBitmapCropped(Bitmap croppedBitmap);
40
41 /**
42 * Called on an error during the crop. If a Throwable was caught along the way, it is passed
43 * here.
44 */
45 void onError(@Nullable Throwable e);
46 }
47}