layer colorification

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

layer colorification

Peter Oslanec-2
Hi, I would like to ask somebody for some tips:

I have this picture (
http://www.materialing.whian.net/files/upload/example.png)  with layers
(black and white). I would like to change colour of each layer: for example
layer 1 could be colour X, layer 2 could be X+1 and so on. But I need to
automate this process (maybe write some macro?). I have no programming
skills and only limited free time,so I need somebody who will be so kind and
guide me into writing macros (if there is no other way how to do it). Thanks
in advance.

With best regards Peto.
Reply | Threaded
Open this post in threaded view
|

Re: layer colorification

dscho
Hi,

On Fri, 28 Nov 2008, Peter Oslanec wrote:

> I have this picture (
> http://www.materialing.whian.net/files/upload/example.png)  with layers
> (black and white). I would like to change colour of each layer: for example
> layer 1 could be colour X, layer 2 could be X+1 and so on. But I need to
> automate this process (maybe write some macro?). I have no programming
> skills and only limited free time,so I need somebody who will be so kind and
> guide me into writing macros (if there is no other way how to do it). Thanks
> in advance.

Try this (you need to create a new macro with Plugins>New>Macro and paste
this text):

-- snip --
w = getWidth();                                 // get dimensions
h = getHeight();

previousColor = -1;                             // color the previous line had

newColor = -1;                                  // new color of current layer

for (y = 0; y < h; y++) {                       // iterate over all lines

        if (getPixel(0, y) != previousColor) {  // if the color has changed,
                previousColor = getPixel(0, y); // remember the color and
                newColor = newColor + 1;        // increment the new color
        }

        for (x = 0; x < w; x++)                 // assign new color to line
                setPixel(x, y, newColor);
}

setMinAndMax(0, newColor);                      // adjust contrast
-- snap --

Hth,
Dscho