Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6581 leency 1
--SCENE: Remap pic to RGB, diag.dith
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
-- Set Palette (to a predefined one)
13
 
14
colors = {{  0,  0,  0},
15
          {255,  0,  0},
16
          {  0,255,  0},
17
          {  0,  0,255}
18
         }
19
 
20
 
21
chm = {1,0,0}
22
 
23
for c = 1, #colors, 1 do
24
  setcolor(c-1,colors[c][1],colors[c][2],colors[c][3])
25
end
26
 
27
for c = #colors, 255, 1 do
28
  setcolor(c,0,0,0)
29
end
30
 
31
 
32
 
33
w, h = getpicturesize()
34
 
35
for y = 0, h - 1, 1 do
36
 
37
  for x = 0, w - 1, 1 do
38
 
39
    r,g,b = getbackupcolor(getbackuppixel(x,y));
40
 
41
      rn = r * chm[1+(y+0+x)%3]
42
      gn = g * chm[1+(y+1+x)%3]
43
      bn = b * chm[1+(y+2+x)%3]
44
 
45
      n = matchcolor(rn,gn,bn);
46
 
47
      putpicturepixel(x, y, n);
48
 
49
  end
50
end