Check-in [7182389a97]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:added library qrencode
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:7182389a979353bda3d9480972289816eb648c34
User & Date: aldo 2018-12-09 17:58:12
Context
2019-04-11
18:15
add sql field to sqlite3 statement Leaf check-in: 538cf8286e user: aldo tags: trunk
2018-12-09
17:58
added library qrencode check-in: 7182389a97 user: aldo tags: trunk
15:41
fixed bug for in args-fold.sls thanks to anonymous check-in: 723d9456e8 user: aldo tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added qrencode.sls.







































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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

(library (qrencode)
  (export qr-encode-string-8bit
	  qr-encode-init
	  qr-encode-mode
	  qr-ec-level
	  qrcode-width
	  qrcode-version
	  qrcode-data
	  qrcode-data-ref
	  QRcode)
  (import (chezscheme) (ffi-utils))
  
  (define-enumeration* qr-ec-level (L M Q H))
  
  (define-flags qr-encode-mode
    (nul -1) (num 0) (an 1) (bit8 2) (kanji 3) (structure 4) (eci 5) (fnc1first 6) (fnc1second 7))
    
  (define-ftype QRcode (struct (version int) (width int) (data (* unsigned-8))))

  (define (qr-encode-init)
    (load-shared-object "libqrencode.so"))

  (define (qr-encode-string-8bit str version level)
    ((foreign-procedure "QRcode_encodeString8bit" (string int int) (* QRcode))
     str version (qr-ec-level level)))
  
  (define (qrcode-width qrcode)
    (ftype-ref QRcode (width) qrcode))

  (define (qrcode-version qrcode)
    (ftype-ref QRcode (version) qrcode))

  (define (qrcode-data qrcode)
    (ftype-ref QRcode (data) qrcode))

  (define (qrcode-data-ref qrcode index)
    (ftype-ref QRcode (data index) qrcode)))


; EXAMPLE
#;(let* ([x (qr-encode-string-8bit "Chez Scheme" 1 'Q)]
       [w (qrcode-width x)])
  (for-each
   (lambda (i)
     (when (= 0 (remainder i w)) (newline))
     (if (= 1 (bitwise-and 1 (qrcode-data-ref x i)))
	 (display "\x2588;")
	 (display " ")))
   (iota (expt w 2))))