• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ QRcode_encodeString函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中QRcode_encodeString函数的典型用法代码示例。如果您正苦于以下问题:C++ QRcode_encodeString函数的具体用法?C++ QRcode_encodeString怎么用?C++ QRcode_encodeString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了QRcode_encodeString函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: test_decodeVeryLong

void test_decodeVeryLong(void)
{
	char str[4000];
	int i;
	QRcode *qrcode;
	QRdata *qrdata;

	testStart("Test code words (very long string).");

	for(i=0; i<3999; i++) {
		str[i] = decodeAnTable[(int)drand(45)];
	}
	str[3999] = '\0';

	qrcode = QRcode_encodeString(str, 0, QR_ECLEVEL_L, QR_MODE_8, 0);
	qrdata = QRcode_decode(qrcode);

	assert_nonnull(qrdata, "Failed to decode.\n");
	if(qrdata != NULL) {
		assert_equal(strlen(str), qrdata->size, "Lengths of input/output mismatched.\n");
		assert_zero(strncmp(str, (char *)(qrdata->data), qrdata->size), "Decoded data %s is different from the original %s\n", qrdata->data, str);
	}
	if(qrdata != NULL) QRdata_free(qrdata);
	if(qrcode != NULL) QRcode_free(qrcode);

	testFinish();
}
开发者ID:zapster,项目名称:libqrencode,代码行数:27,代码来源:test_qrencode.c


示例2: getline

bool qr::encode(std::istream& in, uint32_t version, error_recovery_level level,
    encode_mode mode, bool case_sensitive, std::ostream& out)
{
    std::string qr_string;
    getline(in, qr_string);

    const auto qrcode = QRcode_encodeString(qr_string.c_str(), version,
        level, mode, case_sensitive);

    if (qrcode == nullptr)
        return false;

    const auto area = qrcode->width * qrcode->width;
    if ((area == 0) || (qrcode->width > max_int32 / qrcode->width))
        return false;

    auto width_ptr = reinterpret_cast<const uint8_t*>(&qrcode->width);
    auto version_ptr = reinterpret_cast<const uint8_t*>(&qrcode->version);

    // Write out raw format of QRcode structure (defined in qrencode.h).
    // Format written is:
    // int version
    // int width
    // unsigned char* data (of width^2 length)
    ostream_writer sink(out);
    sink.write_bytes(version_ptr, sizeof(int));
    sink.write_bytes(width_ptr, sizeof(int));
    sink.write_bytes(qrcode->data, area);
    out.flush();

    return true;
}
开发者ID:RojavaCrypto,项目名称:libbitcoin,代码行数:32,代码来源:qrcode.cpp


示例3: painter

void QRWidget::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    QRcode *qrcode = QRcode_encodeString(data.constData(), 1, QR_ECLEVEL_L, QR_MODE_8, 1);
    if (qrcode != NULL) {
        QColor fg(Qt::black);
        QColor bg(Qt::white);
        painter.setBrush(bg);
        painter.setPen(Qt::NoPen);
        const double w = width();
        const double h = height();
        painter.drawRect(0, 0, w, h);
        painter.setBrush(fg);
        const int s = qrcode->width > 0 ? qrcode->width : 1;
        const double aspect = w / h;
        const double scale = ((aspect > 1.0) ? h : w) / s;
        for(int y = 0; y < s; y++){
            const int yy = y * s;
            for(int x = 0; x < s; x++){
                const int xx = yy + x;
                const unsigned char b = qrcode->data[xx];
                if(b &0x01){
                    const double rx1 = x * scale, ry1 = y * scale;
                    QRectF r(rx1, ry1, scale, scale);
                    painter.drawRects(&r,1);
                }
            }
        }
        QRcode_free(qrcode);
    }
    else {
        qWarning() << tr("Generating QR code failed.");
    }
}
开发者ID:CzBiX,项目名称:shadowsocks-qt5,代码行数:34,代码来源:qrwidget.cpp


示例4: QRcode_encodeString

	/*
	 * Qrcode data encoding, implements Barcode2dBase::encode()
	 */
	bool BarcodeQrcode::encode( const std::string& cookedData, Matrix<bool>& encodedData )
	{
		QRcode *qrcode = QRcode_encodeString( cookedData.c_str(), 0, QR_ECLEVEL_M, QR_MODE_8, 1 );
		if ( qrcode == NULL )
		{
			return false;
		}


		int w = qrcode->width;
		encodedData.resize( w, w );
		
		
		for ( int iy = 0; iy < w; iy++ )
		{
			for ( int ix = 0; ix < w; ix++ )
			{
				encodedData[iy][ix] = qrcode->data[ iy*w + ix ] & 0x01;
			}
		}


		QRcode_free( qrcode );
		QRcode_clearCache();

		return true;
	}
开发者ID:bigboss888,项目名称:glabels-qt,代码行数:30,代码来源:BarcodeQrcode.cpp


示例5: QRcode_encodeString

QImage TcQrencode::encodeImage(const QString& s, int bulk)
{
    QImage ret;
    QRcode* qr = QRcode_encodeString(s.toUtf8(), 1, QR_ECLEVEL_Q, QR_MODE_8, 0);
    if ( qr != NULL )
    {

        int allBulk = (qr->width) * bulk;
        ret = QImage(allBulk, allBulk, QImage::Format_Mono);
        QPainter painter(&ret);
        QColor fg("black");
        QColor bg("white");
        painter.setBrush(bg);
        painter.setPen(Qt::NoPen);
        painter.drawRect(0, 0, allBulk, allBulk);

        painter.setBrush(fg);
        for( int y=0; y<qr->width; y++ )
        {
            for( int x=0; x<qr->width; x++ )
            {
                if ( qr->data[y*qr->width+x] & 1 )
                {
                    QRectF r(x*bulk, y*bulk, bulk, bulk);
                    painter.drawRects(&r, 1);
                }
            }
        }
        QRcode_free(qr);
    }
    return ret;
}
开发者ID:eilin1208,项目名称:QT_Test,代码行数:32,代码来源:tcQrencode.cpp


示例6: getURI

void QRCodeDialog::genCode()
{
    QString uri = getURI();

    if (uri != "")
    {
        ui->lblQRCode->setText("");

        QRcode *code = QRcode_encodeString(uri.toUtf8().constData(), 0, QR_ECLEVEL_L, QR_MODE_8, 1);
        if (!code)
        {
            ui->lblQRCode->setText(tr("Error encoding URI into QR Code."));
            return;
        }
        myImage = QImage(code->width + 8, code->width + 8, QImage::Format_RGB32);
        myImage.fill(0xffffff);
        unsigned char *p = code->data;
        for (int y = 0; y < code->width; y++)
        {
            for (int x = 0; x < code->width; x++)
            {
                myImage.setPixel(x + 4, y + 4, ((*p & 1) ? 0x0 : 0xffffff));
                p++;
            }
        }
        QRcode_free(code);
        ui->lblQRCode->setPixmap(QPixmap::fromImage(myImage).scaled(300, 300));
    }
    else
        ui->lblQRCode->setText(tr("Resulting URI too long, try to reduce the text for label / message."));
}
开发者ID:Iamhumanareyou,项目名称:EmprendeCoin,代码行数:31,代码来源:qrcodedialog.cpp


示例7: QRimage_encode

QRcode* QRimage_encode(QRimageEncodeParams* params)
{
	QRcode *code;

	if (NULL == params) {
		return NULL;
	}

	if(params->micro) {
		if(params->eightbit) {
			code = QRcode_encodeDataMQR(params->size, 
				params->data, params->version, params->level);
		} else {
			code = QRcode_encodeStringMQR((char *)params->data, params->version,
				params->level, params->hint, params->casesensitive);
		}
	} else {
		if(params->eightbit) {
			code = QRcode_encodeData(params->size, 
				params->data, params->version, params->level);
		} else {
			code = QRcode_encodeString((char *)params->data, params->version,
				params->level, params->hint, params->casesensitive);
		}
	}
	return code;
}
开发者ID:wxxweb,项目名称:w2x,代码行数:27,代码来源:qrimage.c


示例8: qrencode

char *
qrencode( UDF_INIT* initid, UDF_ARGS* args, unsigned long *length, char* is_null, char *error ) {

	struct mem_encode state;
	state.buffer = NULL;
	state.size = 0;

	QRcode *qrcode = NULL;
	qrcode = QRcode_encodeString( args->args[0], 0, QR_ECLEVEL_H, QR_MODE_8, 1);
	if ( qrcode ) {
		qrcode_to_png( &state, qrcode );
		if ( state.buffer ) {
			initid->ptr = state.buffer;
			*length = state.size;
			fprintf( stderr, "qrcode size = %lu\n", *length );
			fflush(stderr);

		} else {
			*is_null = 1;
			*error = 1;
        	initid->ptr = 0;		
		}
		QRcode_free( qrcode );
	} else {
		*is_null = 1;
		*error = 1;
        initid->ptr = 0;	
	}
	
	return initid->ptr;
}
开发者ID:lucasepe,项目名称:lib_mysqludf_qrencode,代码行数:31,代码来源:lib_mysqludf_qrencode.c


示例9: gl_barcode_iec18004_new

lglBarcode *
gl_barcode_iec18004_new (const gchar    *id,
                         gboolean        text_flag,
                         gboolean        checksum_flag,
                         gdouble         w,
                         gdouble         h,
                         const gchar    *digits)
{
        gint             i_width, i_height;
        lglBarcode      *gbc;
        QRcode          *qrcode;

        if ( *digits == '\0' )
        {
                return NULL;
        }

        i_width  = 0;
        i_height = 0;

        qrcode = QRcode_encodeString ((const char *)digits, 0, QR_ECLEVEL_M,
                                      QR_MODE_8, 1);
        if (qrcode == NULL)
        {
                return NULL;
        }
        
        i_width = i_height = qrcode->width;
        gbc = render_iec18004 ((const gchar *)qrcode->data, i_width, i_height,
                               w, h);

        QRcode_free ( qrcode );

        return gbc;
}
开发者ID:DroiDev,项目名称:glabels,代码行数:35,代码来源:bc-iec18004.c


示例10: test_encode_kanji

void test_encode_kanji(int num)
{
	QRcode *qrcode;
	QRdata *qrdata;
	int len, ret;

	len = fill8bitString();

	qrcode = QRcode_encodeString((char *)data, 0, num % 4, QR_MODE_8, 1);
	if(qrcode == NULL) {
		if(errno == ERANGE) return;
		perror("test_encdoe_kanji aborted at QRcode_encodeString():");
		return;
	}
	qrdata = QRcode_decode(qrcode);
	if(qrdata == NULL) {
		printf("#%d: Failed to decode this code.\n", num);
		QRcode_free(qrcode);
		return;
	}
	if(qrdata->size != len) {
		printf("#%d: length mismatched (orig: %d, decoded: %d)\n", num, len, qrdata->size);
	}
	ret = memcmp(qrdata->data, data, len);
	if(ret != 0) {
		printf("#%d: data mismatched.\n", num);
	}
	QRdata_free(qrdata);
	QRcode_free(qrcode);
}
开发者ID:01org,项目名称:irk_host_linux,代码行数:30,代码来源:test_monkey.c


示例11: QRcode_encodeString

void QRcodeWidget::setUrl(const char *url)
{
    code = QRcode_encodeString(url, 0, QR_ECLEVEL_H, QR_MODE_8, 1);
    if (code != NULL) {
        this->repaint();
    }
}
开发者ID:binape,项目名称:ybb-apitool,代码行数:7,代码来源:qrcodewidget.cpp


示例12: printQRCode

void printQRCode(const char *url) {

	QRcode *qrcode = QRcode_encodeString("http://localhost/btctl.apk", /*version*/0, QR_ECLEVEL_M, /*hint*/ QR_MODE_8, /*casesensitive*/ 1 );
	printf("qrcode: %p\n", qrcode);
	if(qrcode) {
		// const char *BYTES[] = {" ", /*50%oben*/ "\xE2\x96\x80", /*50%unten*/ "\xE2\x96\x84", /*100%*/ "\xE2\x96\x88"};
		const char *BYTES_INVERTED[] = {/*100%*/ "\xE2\x96\x88", /*50%unten*/ "\xE2\x96\x84", /*50%oben*/ "\xE2\x96\x80", " "};
		printf("version: %d, width: %d\n\n",qrcode->version, qrcode->width);
		for(int x=0; x < qrcode->width+2; x++) printf(BYTES_INVERTED[1]);
		printf("\n");
		for(int y=0; y < qrcode->width; y++) {
			printf(BYTES_INVERTED[0]);
			for(int x=0; x < qrcode->width; x++) {
				int val=qrcode->data[y*qrcode->width + x] & 1;
				if((y+1) < qrcode->width) {
					val|=(qrcode->data[(y+1)*qrcode->width + x] & 1) << 1; // nächste zeile 
				}
					// 1=black/0=white
				printf(BYTES_INVERTED[val]);
			}
			y++;
			printf(BYTES_INVERTED[0]);
			printf("\n");
		}
		for(int x=0; x < qrcode->width+2; x++) printf(BYTES_INVERTED[2]);
		printf("\n");
		QRcode_free(qrcode);
		printf("\n");
	} else {
		printf("error: %m\n"); // %m = strerror(errno) ohne argument
		exit(1);
	}

	return;
}
开发者ID:ferbar,项目名称:btcontrol,代码行数:35,代码来源:qrcode.cpp


示例13: setWindowTitle

void ReceiveRequestDialog::update()
{
    if(!model)
        return;
    QString target = info.label;
    if(target.isEmpty())
        target = info.address;
    setWindowTitle(tr("Request payment to %1").arg(target));

    QString uri = GUIUtil::formatDarcoinURI(info);
    ui->btnSaveAs->setEnabled(false);
    QString html;
    html += "<html><font face='verdana, arial, helvetica, sans-serif'>";
    html += "<b>"+tr("Payment information")+"</b><br>";
    html += "<b>"+tr("URI")+"</b>: ";
    html += "<a href=\""+uri+"\">" + GUIUtil::HtmlEscape(uri) + "</a><br>";
    html += "<b>"+tr("Address")+"</b>: " + GUIUtil::HtmlEscape(info.address) + "<br>";
    if(info.amount)
        html += "<b>"+tr("Amount")+"</b>: " + DarcoinUnits::formatWithUnit(model->getDisplayUnit(), info.amount) + "<br>";
    if(!info.label.isEmpty())
        html += "<b>"+tr("Label")+"</b>: " + GUIUtil::HtmlEscape(info.label) + "<br>";
    if(!info.message.isEmpty())
        html += "<b>"+tr("Message")+"</b>: " + GUIUtil::HtmlEscape(info.message) + "<br>";
    ui->outUri->setText(html);

#ifdef USE_QRCODE
    ui->lblQRCode->setText("");
    if(!uri.isEmpty())
    {
        // limit URI length
        if (uri.length() > MAX_URI_LENGTH)
        {
            ui->lblQRCode->setText(tr("Resulting URI too long, try to reduce the text for label / message."));
        } else {
            QRcode *code = QRcode_encodeString(uri.toUtf8().constData(), 0, QR_ECLEVEL_L, QR_MODE_8, 1);
            if (!code)
            {
                ui->lblQRCode->setText(tr("Error encoding URI into QR Code."));
                return;
            }
            QImage myImage = QImage(code->width + 8, code->width + 8, QImage::Format_RGB32);
            myImage.fill(0xffffff);
            unsigned char *p = code->data;
            for (int y = 0; y < code->width; y++)
            {
                for (int x = 0; x < code->width; x++)
                {
                    myImage.setPixel(x + 4, y + 4, ((*p & 1) ? 0x0 : 0xffffff));
                    p++;
                }
            }
            QRcode_free(code);

            ui->lblQRCode->setPixmap(QPixmap::fromImage(myImage).scaled(300, 300));
            ui->btnSaveAs->setEnabled(true);
        }
    }
#endif
}
开发者ID:seraph1188,项目名称:darcoin,代码行数:59,代码来源:receiverequestdialog.cpp


示例14: MakeCodeA

QRcode* MakeCodeA(LPSTR text)
{
	if (text == NULL)
		return NULL;

	QRcode* result = QRcode_encodeString(text, 0, QR_ECLEVEL_H, QR_MODE_8, 1);

	return result;
}
开发者ID:stievie,项目名称:Martis,代码行数:9,代码来源:quricol.cpp


示例15: test_encode2

void test_encode2(void)
{
	QRcode *qrcode;

	testStart("Test encode (2-H) (no padding test)");
	qrcode = QRcode_encodeString("abcdefghijk123456789012", 0, QR_ECLEVEL_H, QR_MODE_8, 0);
	testEndExp(qrcode->version == 2);
	QRcode_free(qrcode);
}
开发者ID:zapster,项目名称:libqrencode,代码行数:9,代码来源:test_qrencode.c


示例16: QRcode_free

/**
 *  功能描述: 设置生成Qrcode的字符串
 *  @param str 这里是Qrchannel的id
 *
 *  @return 无
 */
void QrCode::setString(QString str)
{
    string = str;
    if(qr != NULL) {
        QRcode_free(qr);
    }
    qr = QRcode_encodeString(string.toStdString().c_str(),
                             1, QR_ECLEVEL_L, QR_MODE_8, 1);
    return;
}
开发者ID:v2hack,项目名称:ShadowTalk,代码行数:16,代码来源:st_qrcode.cpp


示例17: test_encodeEmpty

void test_encodeEmpty(void)
{
	QRcode *qrcode;

	testStart("Test encode an empty string.");
	qrcode = QRcode_encodeString("", 0, QR_ECLEVEL_H, QR_MODE_8, 0);
	assert_null(qrcode, "QRcode_encodeString() returned something.\n");
	testFinish();
	if(qrcode != NULL) QRcode_free(qrcode);
}
开发者ID:zapster,项目名称:libqrencode,代码行数:10,代码来源:test_qrencode.c


示例18: QString

void server::toolbar_actiontriggered(QAction *tem)
{
    //工具栏按钮点击
    if(tem->text() == QString("主页")){
        ui->homepage->show();
    }else{
        ui->homepage->hide();
    }

    if(tem->text() == QString("传输中")){
        ui->transfering->show();
    }else{
        ui->transfering->hide();
    }

    if(tem->text() == QString("传输文件")){

    }
    if(tem->text() == QString("二维码")){
        QImage ret;
        int bulk = 8;
        QString str = QString("http://")+ip;
        QRcode* qr = QRcode_encodeString(str.toUtf8(), 1, QR_ECLEVEL_Q, QR_MODE_8, 0);
        if ( qr != nullptr )
        {
            int allBulk = (qr->width) * bulk;
            ret = QImage(allBulk, allBulk, QImage::Format_Mono);
            QPainter painter(&ret);
            QColor fg("black");
            QColor bg("white");
            painter.setBrush(bg);
            painter.setPen(Qt::NoPen);
            painter.drawRect(0, 0, allBulk, allBulk);

            painter.setBrush(fg);
            for( int y=0; y<qr->width; y++ )
            {
                for( int x=0; x<qr->width; x++ )
                {
                    if ( qr->data[y*qr->width+x] & 1 )
                    {
                        QRectF r(x*bulk, y*bulk, bulk, bulk);
                        painter.drawRects(&r, 1);
                    }
                }
            }
            QRcode_free(qr);
        }
        ui->qrcode_l->setPixmap(QPixmap::fromImage(ret));
        ui->qrcode->show();
    }else{
        ui->qrcode->hide();
    }
}
开发者ID:security-geeks,项目名称:ls,代码行数:54,代码来源:server.cpp


示例19: QRcode_encodeString8bit

static QRcode *encode(const char *intext)
{
	QRcode *code;

	if(eightbit) {
		code = QRcode_encodeString8bit(intext, version, level);
	} else {
		code = QRcode_encodeString(intext, version, level, hint, casesensitive);
	}

	return code;
}
开发者ID:OldFrank,项目名称:qrencode,代码行数:12,代码来源:qrenc.c


示例20: painter

//http://stackoverflow.com/questions/21400254/how-to-draw-a-qr-code-with-qt-in-native-c-c
void QRWidget::paintImage()
{
    QPainter painter(image);
    //NOTE: I have hardcoded some parameters here that would make more sense as variables.
    // ECLEVEL_M is much faster recognizable by barcodescanner any any other type
    // https://fukuchi.org/works/qrencode/manual/qrencode_8h.html#a4cebc3c670efe1b8866b14c42737fc8f
    // any mode other than QR_MODE_8 or QR_MODE_KANJI results in EINVAL. First 1 is version, second is case sensitivity
    QRcode* qr = QRcode_encodeString(data.toStdString().c_str(), 1, QR_ECLEVEL_M, QR_MODE_8, 1);

    if (qr != nullptr)
    {
        QColor fg("black");
        QColor bg("white");
        painter.setBrush(bg);
        painter.setPen(Qt::NoPen);
        painter.drawRect(0, 0, size.width(), size.height());
        painter.setBrush(fg);
        const int s = qr->width > 0 ? qr->width : 1;
        const double w = width();
        const double h = height();
        const double aspect = w / h;
        const double scale = ((aspect > 1.0) ? h : w) / s;

        for (int y = 0; y < s; y++)
        {
            const int yy = y * s;
            for (int x = 0; x < s; x++)
            {
                const int xx = yy + x;
                const unsigned char b = qr->data[xx];
                if (b & 0x01)
                {
                    const double rx1 = x * scale,
                                 ry1 = y * scale;
                    QRectF r(rx1, ry1, scale, scale);
                    painter.drawRects(&r, 1);
                }
            }
        }
        QRcode_free(qr);
    }
    else
    {
        QColor error("red");
        painter.setBrush(error);
        painter.drawRect(0, 0, width(), height());
        qDebug() << "QR FAIL: " << strerror(errno);
    }

    qr = nullptr;
}
开发者ID:CuiZhicheng,项目名称:qTox,代码行数:52,代码来源:qrwidget.cpp



注:本文中的QRcode_encodeString函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ QRcode_free函数代码示例发布时间:2022-05-30
下一篇:
C++ QQuaternion函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap