Removed an extra memcpy and made getMatrix() pure virtual.

git-svn-id: https://zxing.googlecode.com/svn/trunk@1556 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
dswitkin@google.com 2010-08-24 18:59:26 +00:00
parent 8f1401656a
commit 3d9063dd17
4 changed files with 4 additions and 21 deletions

View file

@ -28,19 +28,6 @@ LuminanceSource::LuminanceSource() {
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;
}

View file

@ -34,7 +34,7 @@ public:
// 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);

View file

@ -2,8 +2,7 @@
* 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.

View file

@ -42,7 +42,6 @@ unsigned char* GreyscaleRotatedLuminanceSource::getRow(int y, unsigned char* row
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];
}
@ -56,12 +55,10 @@ unsigned char* GreyscaleRotatedLuminanceSource::getRow(int y, unsigned char* row
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;
}