GreyscaleRotatedLuminanceSource: implemented getMatrix()
[zxing.git] / cpp / core / src / zxing / LuminanceSource.cpp
1 /*
2  *  LuminanceSource.cpp
3  *  zxing
4  *
5  *  Copyright 2008 ZXing authors All rights reserved.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 #include <zxing/LuminanceSource.h>
21 #include <zxing/common/IllegalArgumentException.h>
22
23 namespace zxing {
24
25 LuminanceSource::LuminanceSource() {
26 }
27
28 LuminanceSource::~LuminanceSource() {
29 }
30
31 unsigned char* LuminanceSource::getMatrix() {
32   int width = getWidth();
33   int height =  getHeight();
34   unsigned char* matrix = new unsigned char[width * height];
35   unsigned char* row = new unsigned char[width];
36   for (int y = 0; y < height; y++) {
37     row = getRow(y, row);
38     memcpy(&matrix[y * width], row, width);
39   }
40   delete [] row;
41   return matrix;
42 }
43
44 bool LuminanceSource::isCropSupported() const {
45   return false;
46 }
47
48 Ref<LuminanceSource> LuminanceSource::crop(int left, int top, int width, int height) {
49   throw IllegalArgumentException("This luminance source does not support cropping.");
50 }
51
52 bool LuminanceSource::isRotateSupported() const {
53   return false;
54 }
55
56 Ref<LuminanceSource> LuminanceSource::rotateCounterClockwise() {
57   throw IllegalArgumentException("This luminance source does not support rotation.");
58 }
59
60 }