/* * Copyright 2011 QZXing authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef CAMERAIMAGE_H #define CAMERAIMAGE_H #include #include #include using namespace zxing; class CameraImageWrapper : public LuminanceSource { public: CameraImageWrapper(); CameraImageWrapper(const QImage& sourceImage); CameraImageWrapper(CameraImageWrapper& otherInstance); ~CameraImageWrapper(); static QSharedPointer Factory(const QImage& image, int maxWidth=-1, int maxHeight=-1, bool smoothTransformation=false); QSharedPointer> > > getOriginalImage(); QSharedPointer getDelegate() { return delegate; } QSharedPointer> getRow(int y, QSharedPointer> row) const; QSharedPointer> getMatrix() const; bool isCropSupported() const; QSharedPointer crop(int left, int top, int width, int height) const; bool isRotateSupported() const; QSharedPointer invert() const; QSharedPointer rotateCounterClockwise() const; inline zxing::byte gray(const unsigned int r, const unsigned int g, const unsigned int b); private: QSharedPointer> getRowP(int y, QSharedPointer> row) const; QSharedPointer> getMatrixP() const; void updateImageAsGrayscale(const QImage &origin); QSharedPointer delegate; QSharedPointer>>> imageBytesPerRow; QSharedPointer> imageBytes; static const zxing::byte B_TO_GREYSCALE[256]; static const zxing::byte G_TO_GREYSCALE[256]; static const zxing::byte R_TO_GREYSCALE[256]; }; #endif //CAMERAIMAGE_H