rev: 3827f53bae88e48a594610914ba74b9512ead6dd tukan/testing/test_bitmap.sc -rw-r--r-- 1.4 KiB View raw Log this file
3827f53bae88 — Leonard Ritter * more work on module system 3 months ago
                                                                                
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
using import glm
using import ..tukan.bitmap

inline test-load (dynamic? flip float?)
    print "loading..."
    let img =
        load-bitmap
            .. module-dir "/data/duangle_logo.png"
            components =
                do
                    static-if dynamic? 0
                    else 3
            float = float?
            hdr-gamma = 1.0
            flip = flip
    print img
    do
        assert (img.size == (ivec2 256 256))
        for y in (range 64)
            for x in (range 64)
                let x y = (x * 4) (y * 4)
                let px =
                    static-if dynamic?
                        'fetch img x y 3
                    else
                        'fetch img x y
                let rgb =
                    ivec3
                        *
                            vec3 (unpack px)
                            ? float? 255.0 1.0

                io-write! "\x1b[48;2;"
                io-write! (tostring rgb.r); io-write! ";"
                io-write! (tostring rgb.g); io-write! ";"
                io-write! (tostring rgb.b); io-write! "m  "
            io-write! "\n"
        io-write! "\x1b[0m"

    print "done"

inline test-load3 (x y z)
    print "dynamic?=" x "flip=" y "float?=" z
    test-load x y z

inline test-load2 (x y)
    test-load3 x y true
    test-load3 x y false

inline test-load1 (x)
    test-load2 x true
    test-load2 x false

test-load1 true
test-load1 false