• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MerginMaps / input / 5983636709

26 Aug 2023 07:50AM UTC coverage: 62.064% (+1.1%) from 60.955%
5983636709

push

github

web-flow
Lcov to lnx (#2772)

move lcov to linux tests

7552 of 12168 relevant lines covered (62.06%)

102.52 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/app/qrdecoder.cpp
1
#include "qrdecoder.h"
2

3
#include <QImage>
4
#include <ZXing/ReadBarcode.h>
5

6
static ZXing::ImageFormat formatFromQImage( const QImage &img )
×
7
{
8
  switch ( img.format() )
×
9
  {
10
    case QImage::Format_ARGB32:
×
11
    case QImage::Format_RGB32:
12
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
13
      return ZXing::ImageFormat::BGRX;
×
14
#else
15
      return ImageFormat::XRGB;
16
#endif
17
    case QImage::Format_RGB888:
×
18
      return ZXing::ImageFormat::RGB;
×
19
    case QImage::Format_RGBX8888:
×
20
    case QImage::Format_RGBA8888:
21
      return ZXing::ImageFormat::RGBX;
×
22
    case QImage::Format_Grayscale8:
×
23
      return ZXing::ImageFormat::Lum;
×
24
    default:
×
25
      return ZXing::ImageFormat::None;
×
26
  }
27
}
28

29
QRDecoder::QRDecoder( QObject *parent )
×
30
  : QObject( parent )
×
31
{
32
}
×
33

34
QString QRDecoder::processImage( const QImage capturedImage )
×
35
{
36
  QString resultText;
×
37

38
  if ( mIsDecoding )
×
39
  {
40
    return QString();
×
41
  }
42

43
  setIsDecoding( true );
×
44
  ZXing::ImageFormat imageFormat = formatFromQImage( capturedImage );
×
45
  if ( imageFormat != ZXing::ImageFormat::None )
×
46
  {
47
    ZXing::ImageView imageView( capturedImage.bits(), capturedImage.width(), capturedImage.height(), imageFormat, static_cast<int>( capturedImage.bytesPerLine() ) );
×
48

49
    ZXing::DecodeHints hints = ZXing::DecodeHints()
×
50
                               .setFormats( ZXing::BarcodeFormat::Any )
×
51
                               .setTryRotate( true )
×
52
                               .setTryHarder( true );
×
53

54
    ZXing::Result result = ZXing::ReadBarcode( imageView, hints );
×
55
    if ( result.isValid() )
×
56
    {
57
      const std::string text = result.text();
×
58
      resultText = QString::fromStdString( text.c_str() );
×
59
    }
×
60
  }
×
61
  setIsDecoding( false );
×
62
  return resultText;
×
63
}
×
64

65
bool QRDecoder::isDecoding() const
×
66
{
67
  return mIsDecoding;
×
68
}
69

70
void QRDecoder::setIsDecoding( bool isDecoding )
×
71
{
72
  if ( mIsDecoding == isDecoding )
×
73
  {
74
    return;
×
75
  }
76

77
  mIsDecoding = isDecoding;
×
78
  emit isDecodingChanged( mIsDecoding );
×
79
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc