optimized CameraImageWrapper::getMatrix by removing an extra (uneeded) image copy

This commit is contained in:
favoritas37 2016-02-20 15:31:36 +02:00
parent 07cc5c9c6b
commit ea5c7c1d52
1 changed files with 3 additions and 8 deletions

View File

@ -103,10 +103,11 @@ ArrayRef<char> CameraImageWrapper::getMatrix() const
{
int width = getWidth();
int height = getHeight();
char* matrix = new char[width*height];
char* m = matrix;
ArrayRef<char> tmpRow(0);
ArrayRef<char> arr(width*height);
char* m = &arr[0];
for(int y=0; y<height; y++)
{
@ -119,12 +120,6 @@ ArrayRef<char> CameraImageWrapper::getMatrix() const
m += width * sizeof(unsigned char);
}
ArrayRef<char> arr = ArrayRef<char>(matrix, width*height);
if (matrix) {
delete matrix;
}
return arr;
}