• 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.launcher3.graphics;
17 
18 import android.graphics.Bitmap;
19 
20 import com.android.launcher3.ItemInfoWithIcon;
21 
22 public class BitmapInfo {
23 
24     public Bitmap icon;
25     public int color;
26 
applyTo(ItemInfoWithIcon info)27     public void applyTo(ItemInfoWithIcon info) {
28         info.iconBitmap = icon;
29         info.iconColor = color;
30     }
31 
applyTo(BitmapInfo info)32     public void applyTo(BitmapInfo info) {
33         info.icon = icon;
34         info.color = color;
35     }
36 
fromBitmap(Bitmap bitmap)37     public static BitmapInfo fromBitmap(Bitmap bitmap) {
38         BitmapInfo info = new BitmapInfo();
39         info.icon = bitmap;
40         info.color = ColorExtractor.findDominantColorByHue(bitmap);
41         return info;
42     }
43 }
44