-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapplication.e
More file actions
104 lines (92 loc) · 2.04 KB
/
application.e
File metadata and controls
104 lines (92 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
note
description: "[
Eiffel libqrencode example
Based on C code example https://gist.github.com/syohex/b1aa695dc6ac5dced139#file-qrencode-encode-sample-c
]"
date: "$Date$"
revision: "$Revision$"
EIS: "name=libqrencode example", "src=https://gist.github.com/syohex/b1aa695dc6ac5dced139#file-qrencode-encode-sample-c", "protocol=uri"
class
APPLICATION
inherit
ARGUMENTS_32
create
make
feature {NONE} -- Initialization
make
-- Run application.
local
width: INTEGER
data: STRING
buffer: STRING
y, y_index: INTEGER
x: INTEGER
v: CHARACTER
i: INTEGER
iy, iy_index : INTEGER
ix: INTEGER
do
if attached {QRCODE_STRUCT_API} {QRENCODE_FUNCTIONS}.qrcode_encode_string ("EiffelQRencode", 0, {QREC_LEVEL_ENUM_API}.QR_ECLEVEL_L, {QRENCODE_MODE_ENUM_API}.QR_MODE_8, 1) as l_qrcode then
width := l_qrcode.width * ZOOM_SIZE
if attached l_qrcode.data as l_data then
data := l_data
create buffer.make_filled ('%U',{PLATFORM}.character_8_bytes * width * width)
print ("P1%N" + width.out + " " +width.out +"%N")
from
i := 1
y := 0
until
y >= width
loop
y_index := y * width
from
x := 0
until
x >= width
loop
v := if (data[i].code & 1) /= 0 then '1' else '0' end
from
iy := 0
until
iy >= ZOOM_SIZE
loop
iy_index := y_index + iy * width
from
ix := 0
until
ix >= ZOOM_SIZE
loop
buffer.put (v, iy_index + (x + ix) + 1)
ix := ix + 1
end
iy := iy + 1
end
x := x + ZOOM_SIZE
i := i + 1
end
y := y + ZOOM_SIZE
end
from
y := 0
until
y >= width
loop
from
x := 0
until
x >= width
loop
print(buffer[(y*width + x) + 1])
print(" ")
x := x + 1
end
io.put_new_line
y := y + 1
end
{QRENCODE_FUNCTIONS}.QRcode_free (l_qrcode)
end
end
end
feature -- Constant
ZOOM_SIZE: INTEGER = 2
end