mirror of
https://github.com/zxing/zxing.git
synced 2025-01-12 19:57:27 -08:00
c++ port of r2576
git-svn-id: https://zxing.googlecode.com/svn/trunk@2623 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
849866a07a
commit
44e85392eb
|
@ -18,7 +18,10 @@
|
|||
#include <zxing/ZXing.h>
|
||||
#include <zxing/InvertedLuminanceSource.h>
|
||||
|
||||
using zxing::boolean;
|
||||
using zxing::Ref;
|
||||
using zxing::ArrayRef;
|
||||
using zxing::LuminanceSource;
|
||||
using zxing::InvertedLuminanceSource;
|
||||
|
||||
InvertedLuminanceSource::InvertedLuminanceSource(Ref<LuminanceSource> const& delegate_)
|
||||
|
@ -42,3 +45,24 @@ ArrayRef<char> InvertedLuminanceSource::getMatrix() const {
|
|||
}
|
||||
return invertedMatrix;
|
||||
}
|
||||
|
||||
zxing::boolean InvertedLuminanceSource::isCropSupported() const {
|
||||
return delegate->isCropSupported();
|
||||
}
|
||||
|
||||
Ref<LuminanceSource> InvertedLuminanceSource::crop(int left, int top, int width, int height) const {
|
||||
return Ref<LuminanceSource>(new InvertedLuminanceSource(delegate->crop(left, top, width, height)));
|
||||
}
|
||||
|
||||
boolean InvertedLuminanceSource::isRotateSupported() const {
|
||||
return delegate->isRotateSupported();
|
||||
}
|
||||
|
||||
Ref<LuminanceSource> InvertedLuminanceSource::invert() const {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
Ref<LuminanceSource> InvertedLuminanceSource::rotateCounterClockwise() const {
|
||||
return Ref<LuminanceSource>(new InvertedLuminanceSource(delegate->rotateCounterClockwise()));
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <zxing/ZXing.h>
|
||||
#include <zxing/LuminanceSource.h>
|
||||
|
||||
namespace zxing {
|
||||
|
@ -31,6 +32,15 @@ public:
|
|||
|
||||
ArrayRef<char> getRow(int y, ArrayRef<char> row) const;
|
||||
ArrayRef<char> getMatrix() const;
|
||||
|
||||
boolean isCropSupported() const;
|
||||
Ref<LuminanceSource> crop(int left, int top, int width, int height) const;
|
||||
|
||||
boolean isRotateSupported() const;
|
||||
|
||||
virtual Ref<LuminanceSource> invert() const;
|
||||
|
||||
Ref<LuminanceSource> rotateCounterClockwise() const;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -34,11 +34,7 @@ bool LuminanceSource::isCropSupported() const {
|
|||
return false;
|
||||
}
|
||||
|
||||
Ref<LuminanceSource> LuminanceSource::crop(int left, int top, int width, int height) {
|
||||
(void)left;
|
||||
(void)top;
|
||||
(void)width;
|
||||
(void)height;
|
||||
Ref<LuminanceSource> LuminanceSource::crop(int, int, int, int) const {
|
||||
throw IllegalArgumentException("This luminance source does not support cropping.");
|
||||
}
|
||||
|
||||
|
@ -46,7 +42,7 @@ bool LuminanceSource::isRotateSupported() const {
|
|||
return false;
|
||||
}
|
||||
|
||||
Ref<LuminanceSource> LuminanceSource::rotateCounterClockwise() {
|
||||
Ref<LuminanceSource> LuminanceSource::rotateCounterClockwise() const {
|
||||
throw IllegalArgumentException("This luminance source does not support rotation.");
|
||||
}
|
||||
|
||||
|
@ -74,6 +70,17 @@ LuminanceSource::operator std::string() const {
|
|||
return oss.str();
|
||||
}
|
||||
|
||||
Ref<LuminanceSource> LuminanceSource::invert(Ref<LuminanceSource> const& that) {
|
||||
return Ref<LuminanceSource>(new InvertedLuminanceSource(that));
|
||||
Ref<LuminanceSource> LuminanceSource::invert() const {
|
||||
|
||||
// N.B.: this only works because we use counted objects with the
|
||||
// count in the object. This is _not_ how things like shared_ptr
|
||||
// work. They do not allow you to make a smart pointer from a native
|
||||
// pointer more than once. If we ever switch to (something like)
|
||||
// shared_ptr's, the luminace source is going to have keep a weak
|
||||
// pointer to itself from which it can create a strong pointer as
|
||||
// needed. And, FWIW, that has nasty semantics in the face of
|
||||
// exceptions during construction.
|
||||
|
||||
return Ref<LuminanceSource>
|
||||
(new InvertedLuminanceSource(Ref<LuminanceSource>(const_cast<LuminanceSource*>(this))));
|
||||
}
|
||||
|
|
|
@ -43,13 +43,13 @@ class LuminanceSource : public Counted {
|
|||
virtual ArrayRef<char> getMatrix() const = 0;
|
||||
|
||||
virtual bool isCropSupported() const;
|
||||
virtual Ref<LuminanceSource> crop(int left, int top, int width, int height);
|
||||
virtual Ref<LuminanceSource> crop(int left, int top, int width, int height) const;
|
||||
|
||||
virtual bool isRotateSupported() const;
|
||||
|
||||
static Ref<LuminanceSource> invert(Ref<LuminanceSource> const&);
|
||||
|
||||
virtual Ref<LuminanceSource> rotateCounterClockwise();
|
||||
virtual Ref<LuminanceSource> invert() const;
|
||||
|
||||
virtual Ref<LuminanceSource> rotateCounterClockwise() const;
|
||||
|
||||
operator std::string () const;
|
||||
};
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
namespace zxing {
|
||||
|
||||
typedef char byte;
|
||||
typedef bool boolean;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -37,9 +37,6 @@ public:
|
|||
return this;
|
||||
}
|
||||
void release() {
|
||||
if (count_ == 0 || count_ == 54321) {
|
||||
throw 4711;
|
||||
}
|
||||
count_--;
|
||||
if (count_ == 0) {
|
||||
count_ = 0xDEADF001;
|
||||
|
|
Loading…
Reference in a new issue