blob: 850535e67074dd6e5bd8b854c33455637c8caa02 [file] [log] [blame]
The Android Open Source Project31dd5032009-03-03 19:32:27 -08001/*
2 * Copyright (C) 2008 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
Joe Onoratoa5902522009-07-30 13:37:37 -070017package com.android.launcher2;
The Android Open Source Project31dd5032009-03-03 19:32:27 -080018
19import android.graphics.drawable.Drawable;
20import android.graphics.PixelFormat;
21import android.graphics.Bitmap;
22import android.graphics.Canvas;
23import android.graphics.ColorFilter;
24
25class FastBitmapDrawable extends Drawable {
26 private Bitmap mBitmap;
27
28 FastBitmapDrawable(Bitmap b) {
29 mBitmap = b;
30 }
31
32 @Override
33 public void draw(Canvas canvas) {
34 canvas.drawBitmap(mBitmap, 0.0f, 0.0f, null);
35 }
36
37 @Override
38 public int getOpacity() {
39 return PixelFormat.TRANSLUCENT;
40 }
41
42 @Override
43 public void setAlpha(int alpha) {
44 }
45
46 @Override
47 public void setColorFilter(ColorFilter cf) {
48 }
49
50 @Override
51 public int getIntrinsicWidth() {
52 return mBitmap.getWidth();
53 }
54
55 @Override
56 public int getIntrinsicHeight() {
57 return mBitmap.getHeight();
58 }
59
60 @Override
61 public int getMinimumWidth() {
62 return mBitmap.getWidth();
63 }
64
65 @Override
66 public int getMinimumHeight() {
67 return mBitmap.getHeight();
68 }
69
Joe Onorato0589f0f2010-02-08 13:44:00 -080070 public void setBitmap(Bitmap b) {
71 mBitmap = b;
72 }
73
The Android Open Source Project31dd5032009-03-03 19:32:27 -080074 public Bitmap getBitmap() {
75 return mBitmap;
76 }
77}