Another shot at TCP CLOSE_WAIT issue, and tiny code tweak
[zxing.git] / android / src / com / google / zxing / client / android / BaseLuminanceSource.java
1 /*
2  * Copyright 2009 ZXing authors
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
17 package com.google.zxing.client.android;
18
19 import com.google.zxing.LuminanceSource;
20
21 import android.graphics.Bitmap;
22
23 /**
24  * An extension of LuminanceSource which adds some Android-specific methods.
25  *
26  * @author dswitkin@google.com (Daniel Switkin)
27  */
28 public abstract class BaseLuminanceSource extends LuminanceSource {
29   public BaseLuminanceSource(int width, int height) {
30     super(width, height);
31   }
32
33   /**
34    * Requests the width of the underlying platform's bitmap.
35    *
36    * @return The width in pixels.
37    */
38   public abstract int getDataWidth();
39
40   /**
41    * Requests the height of the underlying platform's bitmap.
42    *
43    * @return The height in pixels.
44    */
45   public abstract int getDataHeight();
46
47   /**
48    * Creates a greyscale Android Bitmap from the YUV data based on the crop rectangle.
49    *
50    * @return An 8888 bitmap.
51    */
52   public abstract Bitmap renderCroppedGreyscaleBitmap();
53
54   /**
55    * Creates a color Android Bitmap from the YUV data, ignoring the crop rectangle.
56    *
57    * @param halfSize If true, downsample to 50% in each dimension, otherwise not.
58    * @return An 8888 bitmap.
59    */
60   public abstract Bitmap renderFullColorBitmap(boolean halfSize);
61 }