mirror of https://github.com/status-im/qzxing.git
Optimize: Return the matrix reference directly instead of copying it.
This removes another copy of frame data, thereby improving the FPS of the QZXingFilter example noticeably.
This commit is contained in:
parent
449a808972
commit
61508f461a
|
@ -58,16 +58,16 @@ ArrayRef<byte> GreyscaleLuminanceSource::getRow(int y, ArrayRef<byte> row) const
|
|||
}
|
||||
|
||||
ArrayRef<byte> GreyscaleLuminanceSource::getMatrix() const {
|
||||
if (left_ == 0 && top_ == 0 && dataWidth_ == getWidth() && dataHeight_ == getHeight()) {
|
||||
return greyData_;
|
||||
} else {
|
||||
int size = getWidth() * getHeight();
|
||||
ArrayRef<byte> result (size);
|
||||
if (left_ == 0 && top_ == 0 && dataWidth_ == getWidth() && dataHeight_ == getHeight()) {
|
||||
memcpy(&result[0], &greyData_[0], size);
|
||||
} else {
|
||||
for (int row = 0; row < getHeight(); row++) {
|
||||
memcpy(&result[row * getWidth()], &greyData_[(top_ + row) * dataWidth_ + left_], getWidth());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Ref<LuminanceSource> GreyscaleLuminanceSource::rotateCounterClockwise() const {
|
||||
|
|
Loading…
Reference in New Issue