Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6581 leency 1
--SCENE: Remap pic to 3bit, LineEDdith. (Same line simple error-diffusion dither)
2
--by Richard Fhager
3
--http://hem.fyristorg.com/dawnbringer/
4
 
5
-- Copyright 2010 Richard Fhager
6
--
7
-- This program is free software; you can redistribute it and/or
8
-- modify it under the terms of the GNU General Public License
9
-- as published by the Free Software Foundation; version 2
10
-- of the License. See 
11
 
12
--
13
-- Just a demonstration.
14
--
15
 
16
 
17
 
18
power = 0.6
19
 
20
-- Channel shades (shades = 2 ^ bit-depth)
21
shades = 2
22
 
23
mult = 255 / (shades-1)
24
 
25
 
26
colors = {}
27
col = 0
28
for r = 0, shades-1, 1 do
29
  for g = 0, shades-1, 1 do
30
    for b = 0, shades-1, 1 do
31
       col = col + 1
32
       colors[col] = { r*mult, g*mult, b*mult }
33
    end
34
  end
35
end
36
 
37
 
38
for c = 1, #colors, 1 do
39
 
40
  setcolor(c-1,colors[c][1],colors[c][2],colors[c][3])
41
 
42
end
43
 
44
 
45
for c = #colors, 255, 1 do
46
  setcolor(c,0,0,0)
47
end
48
 
49
 
50
 
51
w, h = getpicturesize()
52
 
53
for y = 0, h - 1, 1 do
54
 
55
  re = 0
56
  ge = 0
57
  be = 0
58
 
59
  for x = (y%2), w - 1, 1 do
60
 
61
    r,g,b = getbackupcolor(getbackuppixel(x,y));
62
 
63
      rn = re + r
64
      gn = ge + g
65
      bn = be + b
66
 
67
      n = matchcolor(rn,gn,bn);
68
 
69
    putpicturepixel(x, y, n);
70
 
71
 
72
    rn,gn,bn = getcolor(getpicturepixel(x,y));
73
 
74
    re = (re + (r - rn)) * power
75
    ge = (ge + (g - gn)) * power
76
    be = (be + (b - bn)) * power
77
 
78
 
79
  end
80
end