Removed an extra memcpy and made getMatrix() pure virtual.
authordswitkin@google.com <dswitkin@google.com@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Tue, 24 Aug 2010 18:59:26 +0000 (18:59 +0000)
committerdswitkin@google.com <dswitkin@google.com@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Tue, 24 Aug 2010 18:59:26 +0000 (18:59 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@1556 59b500cc-1b3d-0410-9834-0bbf25fbcc57

cpp/core/src/zxing/LuminanceSource.cpp
cpp/core/src/zxing/LuminanceSource.h
cpp/core/src/zxing/ResultPointCallback.cpp
cpp/core/src/zxing/common/GreyscaleRotatedLuminanceSource.cpp

index 0667d4c..834dba2 100644 (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;
 }
index bbcfa26..68a6e35 100644 (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);
index 72474c9..723942a 100644 (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.
index 25c09db..498b5ea 100644 (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;
 }