Commit c0072e0b authored by Volker Krause's avatar Volker Krause
Browse files

Decrease the preferred size for PDF417 barcodes

Unlike the other two-dimensional codes its smallest output element is not 1x1
but 1x3 pixels, so a scale factor of 2 already gives us enough area for barcode
scanners to work with, and avoids PDF417 barcodes becoming unreasonably large
by default.

The implementation is a bit hacky unfortunately, as surprisingly the base
class has no knowledge about the specific barcode type.
parent 737f6b90
Pipeline #91798 passed with stage
in 34 seconds
......@@ -5,6 +5,8 @@
*/
#include "abstractbarcode.h"
#include "config-prison.h"
#include "pdf417barcode.h"
#include <QColor>
#include <QPainter>
......@@ -152,6 +154,12 @@ QSizeF AbstractBarcode::preferredSize(qreal devicePixelRatio) const
case OneDimension:
return QSizeF(d->m_cache.width() * (devicePixelRatio < 2 ? 2 : 1), std::max(d->m_cache.height(), 50));
case TwoDimensions:
#if HAVE_ZXING
// the smallest element of a PDF417 code is 1x 3px, for Aztec/QR/DataMatrix it's just 1x1 px
if (dynamic_cast<const Pdf417Barcode *>(this)) {
return d->m_cache.size() * (devicePixelRatio < 2 ? 2 : 1);
}
#endif
return d->m_cache.size() * (devicePixelRatio < 2 ? 4 : 2);
}
return {};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment