mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Allow removal of text
This commit is contained in:
parent
57c9ff012c
commit
d5e61c1c44
@ -40,6 +40,8 @@ QZint::QZint()
|
|||||||
m_error=0;
|
m_error=0;
|
||||||
m_input_mode = UNICODE_MODE;
|
m_input_mode = UNICODE_MODE;
|
||||||
m_scale = 1.0;
|
m_scale = 1.0;
|
||||||
|
m_option_3 = 0;
|
||||||
|
m_hidetext = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
QZint::~QZint()
|
QZint::~QZint()
|
||||||
@ -63,13 +65,20 @@ void QZint::encode()
|
|||||||
m_zintSymbol->option_1=m_securityLevel;
|
m_zintSymbol->option_1=m_securityLevel;
|
||||||
m_zintSymbol->input_mode = m_input_mode;
|
m_zintSymbol->input_mode = m_input_mode;
|
||||||
m_zintSymbol->option_2=m_width;
|
m_zintSymbol->option_2=m_width;
|
||||||
m_zintSymbol->option_3=m_pdf417CodeWords;
|
if(m_symbol == BARCODE_PDF417) {
|
||||||
|
m_zintSymbol->option_3=m_pdf417CodeWords;
|
||||||
|
} else {
|
||||||
|
m_zintSymbol->option_3 = m_option_3;
|
||||||
|
}
|
||||||
QByteArray bstr=m_text.toAscii();
|
QByteArray bstr=m_text.toAscii();
|
||||||
QByteArray pstr=m_primaryMessage.left(99).toAscii();
|
QByteArray pstr=m_primaryMessage.left(99).toAscii();
|
||||||
strcpy(m_zintSymbol->primary,pstr.data());
|
strcpy(m_zintSymbol->primary,pstr.data());
|
||||||
int error = ZBarcode_Encode(m_zintSymbol, (unsigned char*)bstr.data(), bstr.length());
|
int error = ZBarcode_Encode(m_zintSymbol, (unsigned char*)bstr.data(), bstr.length());
|
||||||
if (error > WARN_INVALID_OPTION)
|
if (error > WARN_INVALID_OPTION)
|
||||||
m_lastError=m_zintSymbol->errtxt;
|
m_lastError=m_zintSymbol->errtxt;
|
||||||
|
if(m_hidetext) {
|
||||||
|
m_zintSymbol->text[0] = (unsigned char) '\0';
|
||||||
|
}
|
||||||
|
|
||||||
if (m_zintSymbol->symbology == BARCODE_MAXICODE)
|
if (m_zintSymbol->symbology == BARCODE_MAXICODE)
|
||||||
m_zintSymbol->height = 33;
|
m_zintSymbol->height = 33;
|
||||||
@ -131,6 +140,11 @@ void QZint::setWidth(int width)
|
|||||||
m_width=width;
|
m_width=width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QZint::setOption3(int option)
|
||||||
|
{
|
||||||
|
m_option_3 = option;
|
||||||
|
}
|
||||||
|
|
||||||
int QZint::width()
|
int QZint::width()
|
||||||
{
|
{
|
||||||
encode();
|
encode();
|
||||||
@ -222,6 +236,11 @@ void QZint::setMode(int securityLevel)
|
|||||||
m_securityLevel=securityLevel;
|
m_securityLevel=securityLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QZint::setHideText(bool hide)
|
||||||
|
{
|
||||||
|
m_hidetext = hide;
|
||||||
|
}
|
||||||
|
|
||||||
bool QZint::save_to_file(QString filename)
|
bool QZint::save_to_file(QString filename)
|
||||||
{
|
{
|
||||||
if (m_zintSymbol)
|
if (m_zintSymbol)
|
||||||
@ -240,7 +259,11 @@ bool QZint::save_to_file(QString filename)
|
|||||||
m_zintSymbol->option_1=m_securityLevel;
|
m_zintSymbol->option_1=m_securityLevel;
|
||||||
m_zintSymbol->input_mode = m_input_mode;
|
m_zintSymbol->input_mode = m_input_mode;
|
||||||
m_zintSymbol->option_2=m_width;
|
m_zintSymbol->option_2=m_width;
|
||||||
m_zintSymbol->option_3=m_pdf417CodeWords;
|
if(m_symbol == BARCODE_PDF417) {
|
||||||
|
m_zintSymbol->option_3=m_pdf417CodeWords;
|
||||||
|
} else {
|
||||||
|
m_zintSymbol->option_3 = m_option_3;
|
||||||
|
}
|
||||||
m_zintSymbol->scale=m_scale;
|
m_zintSymbol->scale=m_scale;
|
||||||
QByteArray bstr=m_text.toAscii();
|
QByteArray bstr=m_text.toAscii();
|
||||||
QByteArray pstr=m_primaryMessage.left(99).toAscii();
|
QByteArray pstr=m_primaryMessage.left(99).toAscii();
|
||||||
@ -251,7 +274,13 @@ bool QZint::save_to_file(QString filename)
|
|||||||
QByteArray bgcol=bg_colour_hash.right(6).toAscii();
|
QByteArray bgcol=bg_colour_hash.right(6).toAscii();
|
||||||
strcpy(m_zintSymbol->fgcolour,fgcol.data());
|
strcpy(m_zintSymbol->fgcolour,fgcol.data());
|
||||||
strcpy(m_zintSymbol->bgcolour,bgcol.data());
|
strcpy(m_zintSymbol->bgcolour,bgcol.data());
|
||||||
int error = ZBarcode_Encode_and_Print(m_zintSymbol, (unsigned char*)bstr.data(), bstr.length(), 0);
|
int error = ZBarcode_Encode(m_zintSymbol, (unsigned char*)bstr.data(), bstr.length());
|
||||||
|
if (error > WARN_INVALID_OPTION)
|
||||||
|
m_lastError=m_zintSymbol->errtxt;
|
||||||
|
if(m_hidetext) {
|
||||||
|
m_zintSymbol->text[0] = (unsigned char) '\0';
|
||||||
|
}
|
||||||
|
error = ZBarcode_Print(m_zintSymbol, 0);
|
||||||
if (error > WARN_INVALID_OPTION)
|
if (error > WARN_INVALID_OPTION)
|
||||||
m_lastError=m_zintSymbol->errtxt;
|
m_lastError=m_zintSymbol->errtxt;
|
||||||
if(error == 0) { return true; } else { return false; }
|
if(error == 0) { return true; } else { return false; }
|
||||||
|
@ -51,6 +51,8 @@ public:
|
|||||||
void setWidth(int width);
|
void setWidth(int width);
|
||||||
int width();
|
int width();
|
||||||
|
|
||||||
|
void setOption3(int option);
|
||||||
|
|
||||||
QColor fgColor();
|
QColor fgColor();
|
||||||
void setFgColor(const QColor & fgColor);
|
void setFgColor(const QColor & fgColor);
|
||||||
|
|
||||||
@ -88,6 +90,8 @@ public:
|
|||||||
|
|
||||||
bool save_to_file(QString filename);
|
bool save_to_file(QString filename);
|
||||||
|
|
||||||
|
void setHideText(bool hide);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void encode();
|
void encode();
|
||||||
int module_set(int y_coord, int x_coord);
|
int module_set(int y_coord, int x_coord);
|
||||||
@ -110,6 +114,8 @@ private:
|
|||||||
int m_whitespace;
|
int m_whitespace;
|
||||||
zint_symbol * m_zintSymbol;
|
zint_symbol * m_zintSymbol;
|
||||||
float m_scale;
|
float m_scale;
|
||||||
|
int m_option_3;
|
||||||
|
bool m_hidetext;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user