2 * Copyright 2009 ZXing authors
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
17 namespace com.google.zxing
\r
20 /// <summary> The purpose of this class hierarchy is to abstract different bitmap implementations across
\r
21 /// platforms into a standard interface for requesting greyscale luminance values. The interface
\r
22 /// only provides immutable methods; therefore crop and rotation create copies. This is to ensure
\r
23 /// that one Reader does not modify the original luminance source and leave it in an unknown state
\r
24 /// for other Readers in the chain.
\r
27 /// <author> dswitkin@google.com (Daniel Switkin)
\r
29 /// <author>www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source
\r
32 public abstract class LuminanceSource
\r
34 /// <summary> Fetches luminance data for the underlying bitmap. Values should be fetched using:
\r
35 /// int luminance = array[y * width + x] & 0xff;
\r
38 /// <returns> A row-major 2D array of luminance values. Do not use result.length as it may be
\r
39 /// larger than width * height bytes on some platforms. Do not modify the contents
\r
42 public abstract sbyte[] Matrix{get;}
\r
43 /// <returns> The width of the bitmap.
\r
45 virtual public int Width
\r
53 /// <returns> The height of the bitmap.
\r
55 virtual public int Height
\r
63 /// <returns> Whether this subclass supports cropping.
\r
65 virtual public bool CropSupported
\r
73 /// <returns> Whether this subclass supports counter-clockwise rotation.
\r
75 virtual public bool RotateSupported
\r
84 //UPGRADE_NOTE: Final was removed from the declaration of 'width '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
\r
86 //UPGRADE_NOTE: Final was removed from the declaration of 'height '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
\r
89 protected internal LuminanceSource(int width, int height)
\r
92 this.height = height;
\r
95 /// <summary> Fetches one row of luminance data from the underlying platform's bitmap. Values range from
\r
96 /// 0 (black) to 255 (white). Because Java does not have an unsigned byte type, callers will have
\r
97 /// to bitwise and with 0xff for each value. It is preferable for implementations of this method
\r
98 /// to only fetch this row rather than the whole image, since no 2D Readers may be installed and
\r
99 /// getMatrix() may never be called.
\r
102 /// <param name="y">The row to fetch, 0 <= y < getHeight().
\r
104 /// <param name="row">An optional preallocated array. If null or too small, it will be ignored.
\r
105 /// Always use the returned object, and ignore the .length of the array.
\r
107 /// <returns> An array containing the luminance data.
\r
109 public abstract sbyte[] getRow(int y, sbyte[] row);
\r
111 /// <summary> Returns a new object with cropped image data. Implementations may keep a reference to the
\r
112 /// original data rather than a copy. Only callable if isCropSupported() is true.
\r
115 /// <param name="left">The left coordinate, 0 <= left < getWidth().
\r
117 /// <param name="top">The top coordinate, 0 <= top <= getHeight().
\r
119 /// <param name="width">The width of the rectangle to crop.
\r
121 /// <param name="height">The height of the rectangle to crop.
\r
123 /// <returns> A cropped version of this object.
\r
125 public virtual LuminanceSource crop(int left, int top, int width, int height)
\r
127 throw new System.SystemException("This luminance source does not support cropping.");
\r
130 /// <summary> Returns a new object with rotated image data. Only callable if isRotateSupported() is true.
\r
133 /// <returns> A rotated version of this object.
\r
135 public virtual LuminanceSource rotateCounterClockwise()
\r
137 throw new System.SystemException("This luminance source does not support rotation.");
\r