mirror of
https://git.code.sf.net/p/zint/code
synced 2026-01-04 18:57:05 +00:00
backend_qt: new method save_as_memfile() to save as
`BARCODE_MEMORY_FILE` and use in GUI for pasting to clipboard instead of creating temporary file CLI: allow fully case-insensitive "tiff" as filetype (saved as ".tif"), processing up to 4-letter extensions and hopefully making filetype handling more expected; simplify `validate_float()` (unneeded 2nd fractional max test); add some more internal "--test" tests BWIPP: update to latest (change from ctx to global VM) - zint tests work as-is, no change
This commit is contained in:
@@ -967,6 +967,33 @@ namespace Zint {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QZint::save_to_memfile(const QString& filename, QByteArray& data) {
|
||||
if (resetSymbol()) {
|
||||
m_zintSymbol->output_options |= BARCODE_MEMORY_FILE;
|
||||
cpy_bytearray_left(m_zintSymbol->outfile, filename.toUtf8(), ARRAY_SIZE(m_zintSymbol->outfile) - 1);
|
||||
if (m_segs.empty()) {
|
||||
QByteArray bstr = m_text.toUtf8();
|
||||
m_error = ZBarcode_Encode_and_Print(m_zintSymbol, (unsigned char *) bstr.data(), bstr.length(),
|
||||
m_rotate_angle);
|
||||
} else {
|
||||
struct zint_seg segs[maxSegs];
|
||||
std::vector<QByteArray> bstrs;
|
||||
int seg_count = convertSegs(segs, bstrs);
|
||||
m_error = ZBarcode_Encode_Segs_and_Print(m_zintSymbol, segs, seg_count, m_rotate_angle);
|
||||
}
|
||||
}
|
||||
if (m_error >= ZINT_ERROR) {
|
||||
m_lastError = m_zintSymbol->errtxt;
|
||||
m_encodedWidth = m_encodedRows = 0;
|
||||
m_encodedHeight = m_vectorWidth = m_vectorHeight = 0.0f;
|
||||
emit errored();
|
||||
return false;
|
||||
}
|
||||
data = QByteArray((const char *) m_zintSymbol->memfile, m_zintSymbol->memfile_size);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Convert `zint_vector_rect->colour` to Qt color */
|
||||
Qt::GlobalColor QZint::colourToQtColor(int colour) {
|
||||
switch (colour) {
|
||||
|
||||
Reference in New Issue
Block a user