BinaryBitmap.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
  2. /*
  3. * Copyright 2010 ZXing authors All rights reserved.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. #include <zxing/BinaryBitmap.h>
  18. using zxing::Ref;
  19. using zxing::BitArray;
  20. using zxing::BitMatrix;
  21. using zxing::LuminanceSource;
  22. using zxing::BinaryBitmap;
  23. // VC++
  24. using zxing::Binarizer;
  25. BinaryBitmap::BinaryBitmap(Ref<Binarizer> binarizer) : binarizer_(binarizer) {
  26. }
  27. BinaryBitmap::~BinaryBitmap() {
  28. }
  29. Ref<BitArray> BinaryBitmap::getBlackRow(int y, Ref<BitArray> row) {
  30. return binarizer_->getBlackRow(y, row);
  31. }
  32. Ref<BitMatrix> BinaryBitmap::getBlackMatrix() {
  33. return binarizer_->getBlackMatrix();
  34. }
  35. int BinaryBitmap::getWidth() const {
  36. return getLuminanceSource()->getWidth();
  37. }
  38. int BinaryBitmap::getHeight() const {
  39. return getLuminanceSource()->getHeight();
  40. }
  41. Ref<LuminanceSource> BinaryBitmap::getLuminanceSource() const {
  42. return binarizer_->getLuminanceSource();
  43. }
  44. bool BinaryBitmap::isCropSupported() const {
  45. return getLuminanceSource()->isCropSupported();
  46. }
  47. Ref<BinaryBitmap> BinaryBitmap::crop(int left, int top, int width, int height) {
  48. return Ref<BinaryBitmap> (new BinaryBitmap(binarizer_->createBinarizer(getLuminanceSource()->crop(left, top, width, height))));
  49. }
  50. bool BinaryBitmap::isRotateSupported() const {
  51. return getLuminanceSource()->isRotateSupported();
  52. }
  53. Ref<BinaryBitmap> BinaryBitmap::rotateCounterClockwise() {
  54. return Ref<BinaryBitmap> (new BinaryBitmap(binarizer_->createBinarizer(getLuminanceSource()->rotateCounterClockwise())));
  55. }