cuitzhaoqi / awtk-qr Goto Github PK
View Code? Open in Web Editor NEWawtk的二维码插件
License: GNU Lesser General Public License v2.1
awtk的二维码插件
License: GNU Lesser General Public License v2.1
现在我遇到一个问题,创建二维码控件以后,再关闭应用时会出现内存错误。
mem.c如下函数出现异常。
static void tk_free_impl(void* ptr) {
s_mem_stat.used_block_nr--;
free(ptr);
}
测试代码如下:
widget_t *qr_code = qr_create(win, 100, 100, 200, 200);
qr_set_pixsize(qr_code, 5);
qr_set_text(qr_code, "123456789");
widget_set_self_layout_params(qr_code, "c", "50%", "50%", "50%");
widget_set_name(qr_code, "qr_code");
widget_use_style(qr_code, "qr_border");
问题1:创建一个二维码控件
void test(void)
{
assets_manager_t* rm = assets_manager();
assets_manager_load(rm, ASSET_TYPE_FONT, "default");
awtk_set_locale_simplified_chinese();
widget_t new_qr_code = qr_create(cont_obj, 20, 20, 80, 80);
qr_set_pixsize(new_qr_code, 3);
char tr_str[64];
int value = 123456;
const char format = locale_info_tr(locale_info(), "中文%d");
qr_set_text(new_qr_code, tr_str);
widget_set_name(new_qr_code, "new_qr_code");
}
问题:二维码是显示出来的但是我扫描后为什么中文是乱码,是哪地方没搞好吗?
打印出
for(i = 0; i < strlen(tr_str); i++)
{
rt_kprintf("%x ,", tr_str[i]);
}
输出:d6 ,d0 ,ce ,c4 ,31 ,32 ,33 ,34 ,35 ,36 扫码中文是乱码 123456正常 是什么问题?
问题2:我想获得二维码的点数据 我直接qr_t* qr = QR(new_qr_code); 的话得到的qr->qr_code_data是空,qr->qr_width 是 0所以我 如下操作 :
qr_t* qr = QR(new_qr_code);
if (qr->qr_text != NULL)
{
QRcode *qr_code;
qr_code = QRcode_encodeString((const char *)qr->qr_text, 3, QR_ECLEVEL_H,
QR_MODE_8, 1);
qr->qr_code_data = qr_code;
qr->qr_width = qr_code->width;
}
可以得到了宽度和数据。
那么1.能像上面那样操作来获得数据吗?
2.这个qr->qr_code_data 需要我手动QRcode_free吗?貌似我用时有时会导致我系统崩溃
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.