Sepia - RealWorld forums

Log-in or register.

Sepia

PAEz
on October 28th 2013

Sepia

Code
Execution

var image = Document.RasterImage;

var w = image.sizeX;
var h = image.sizeY;
var c,r,g,b,a,x,y,or,og,ob;

for (x=0; x<w; x++){
for (y=0; y<h; y++){

c = image.GetPixel(x,y,0,0);

ob = c & 255;
og = c >> 8 & 255;
or = c >> 16 & 255;
a = c >> 24 & 255;

r = (or * 0.393 + og * 0.769 + ob * 0.189);
g = (or * 0.349 + og * 0.686 + ob * 0.168);
b = (or * 0.272 + og * 0.534 + ob * 0.131);

if (r < 0) r = 0; if (r > 255) r = 255;
if (g < 0) g = 0; if (g > 255) g = 255;
if (b < 0) b = 0; if (b > 255) b = 255;

c=(a << 24) |
  (r << 16) |
  (g <<  8) |
   b;

image.SetPixel(x, y, 0, 0, c);

}
}

Source
Pixtastic
http://www.pixastic.com/
http://www.pixastic.com/lib/git/pixastic/actions/sepia.js

Page views: 1022       Posts: 1      
What about ICL files?
Select background
I wish there were...