Commit 7c7c51ae by nosa

fix a bug when initialize value

parent 889d6e4d
2014-11-03 vinoca <vinoca@vinoca.org>
* qrencode.c:
* fixed a bug when initialize value.
[1.0]
- Bumped verstion to 1.0.2
2014-10-30 vinoca <vinoca@vinoca.org> 2014-10-30 vinoca <vinoca@vinoca.org>
* qrencode.c: * qrencode.c:
* add ansi type. * add ansi type.
[1.0] [1.0]
* add luarocks rockspec. * add luarocks rockspec.
- Bumped verstion to 3.4.4. - Bumped verstion to 1.0.1
2014-10-16 vinoca <vinoca@vinoca.org> 2014-10-16 vinoca <vinoca@vinoca.org>
* Bumped version to 1.0.0. * Bumped version to 1.0.0.
...@@ -28,17 +28,18 @@ print(qr { ...@@ -28,17 +28,18 @@ print(qr {
text="is ok?", text="is ok?",
level="L", level="L",
kanji=false, kanji=false,
ansi=false, ansi=true,
size=3, size=4,
margin=2,
symversion=0, symversion=0,
dpi=80, dpi=78,
casesensitive=true, casesensitive=false,
eightbit=false,
foreground="#48AF6D", foreground="#48AF6D",
background="#3FAF6F" background="#3FAF6F"
} }
) )
``` ```
when pass a table, "text" is required and other is optional. when pass a table, "text" is required and other is optional.
......
...@@ -27,17 +27,11 @@ enum imageType { ...@@ -27,17 +27,11 @@ enum imageType {
#define INCHES_PER_METER (100.0/2.54) #define INCHES_PER_METER (100.0/2.54)
static int casesensitive = 1; static int size;
static int eightbit = 0; static int margin;
static int version = 0; static int dpi;
static int size = 3; static unsigned int fg_color[4];
static int margin = 4; static unsigned int bg_color[4];
static int dpi = 72;
static QRecLevel level = QR_ECLEVEL_L;
static QRencodeMode hint = QR_MODE_8;
static enum imageType image_type = PNG_TYPE;
static unsigned int fg_color[4] = {0, 0, 0, 255};
static unsigned int bg_color[4] = {255, 255, 255, 255};
/* png io callback function */ /* png io callback function */
...@@ -336,12 +330,28 @@ static int encode (lua_State *L) ...@@ -336,12 +330,28 @@ static int encode (lua_State *L)
const char *intext; const char *intext;
struct memData result; struct memData result;
int version = 0;
int casesensitive = 1;
QRencodeMode hint = QR_MODE_8;
QRecLevel level = QR_ECLEVEL_L;
enum imageType image_type = PNG_TYPE;
size = 3;
margin = 4;
dpi = 72;
fg_color[0] = 0;
fg_color[1] = 0;
fg_color[2] = 0;
fg_color[3] = 255;
bg_color[0] = 255;
bg_color[1] = 255;
bg_color[2] = 255;
bg_color[3] = 255;
result.buffer = NULL; result.buffer = NULL;
result.size = 0; result.size = 0;
image_type = PNG_TYPE;
if ((lua_gettop(L) == 1 && lua_istable(L, 1)) || if ((lua_gettop(L) == 1 && lua_istable(L, 1)) ||
lua_gettop(L) == 2 && lua_istable(L, 2)) { (lua_gettop(L) == 2 && lua_istable(L, 2)) ) {
if (lua_gettop(L) == 2) if (lua_gettop(L) == 2)
lua_remove(L, 1); lua_remove(L, 1);
...@@ -408,7 +418,6 @@ static int encode (lua_State *L) ...@@ -408,7 +418,6 @@ static int encode (lua_State *L)
set_qr_int(L, &margin, "margin"); set_qr_int(L, &margin, "margin");
set_qr_int(L, &dpi, "dpi"); set_qr_int(L, &dpi, "dpi");
set_qr_boolean(L,&casesensitive, "casesensitive"); set_qr_boolean(L,&casesensitive, "casesensitive");
set_qr_boolean(L,&eightbit, "eightbit");
set_png_color(L, fg_color, "foreground"); set_png_color(L, fg_color, "foreground");
set_png_color(L, bg_color, "background"); set_png_color(L, bg_color, "background");
} }
...@@ -460,9 +469,8 @@ static const struct luaL_Reg R [] = { ...@@ -460,9 +469,8 @@ static const struct luaL_Reg R [] = {
int luaopen_qrencode (lua_State *L) int luaopen_qrencode (lua_State *L)
{ {
//luaL_register(L, "qrencode", R);
luaL_newlib(L, R); luaL_newlib(L, R);
lua_pushvalue(L, -1); lua_pushvalue(L, -1);
lua_setmetatable(L, -2); lua_setmetatable(L, -2);
return 1; return 1;
} }
......
...@@ -5,19 +5,19 @@ print(qr.encode("is ok?")) ...@@ -5,19 +5,19 @@ print(qr.encode("is ok?"))
print(qr:encode("is ok?")) print(qr:encode("is ok?"))
print(qr("is ok?")) print(qr("is ok?"))
print(qr {text = "is ok?", ansi = true})
print(qr { print(qr {
text="123", text="is ok?",
level="L", level="L",
kanji=false, kanji=false,
ansi=false, ansi=true,
size=3, size=4,
margin=2,
symversion=0, symversion=0,
dpi=80, dpi=78,
casesensitive=true, casesensitive=false,
eightbit=false,
foreground="#48AF6D", foreground="#48AF6D",
background="#3FAF6F" background="#3FAF6F"
} }
) )
print(qr {text = "is ok?", ansi = false})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment