当前位置: 首页>>代码示例>>C++>>正文


C++ QRcode_encodeString函数代码示例

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


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


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