LuminanceSource::~LuminanceSource() {
}
-unsigned char* LuminanceSource::getMatrix() {
- int width = getWidth();
- int height = getHeight();
- unsigned char* matrix = new unsigned char[width * height];
- unsigned char* row = new unsigned char[width];
- for (int y = 0; y < height; y++) {
- row = getRow(y, row);
- memcpy(&matrix[y * width], row, width);
- }
- delete [] row;
- return matrix;
-}
-
bool LuminanceSource::isCropSupported() const {
return false;
}
// Callers take ownership of the returned memory and must call delete [] on it themselves.
virtual unsigned char* getRow(int y, unsigned char* row) = 0;
- virtual unsigned char* getMatrix();
+ virtual unsigned char* getMatrix() = 0;
virtual bool isCropSupported() const;
virtual Ref<LuminanceSource> crop(int left, int top, int width, int height);
* ResultPointCallback.cpp
* zxing
*
- * Created by Christian Brunschen on 13/05/2008.
- * Copyright 2008 ZXing authors All rights reserved.
+ * Copyright 2010 ZXing authors All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
throw IllegalArgumentException("Requested row is outside the image: " + y);
}
int width = getWidth();
- // TODO(flyashi): determine if row has enough size.
if (row == NULL) {
row = new unsigned char[width];
}
unsigned char* GreyscaleRotatedLuminanceSource::getMatrix() {
unsigned char* result = new unsigned char[width_ * height_];
- unsigned char* row = new unsigned char[width_];
+ // This depends on getRow() honoring its second parameter.
for (int y = 0; y < height_; y++) {
- row = getRow(y, row);
- memcpy(result + y * width_, row, width_);
+ getRow(y, &result[y * width_]);
}
- delete [] row;
return result;
}