PosterizeAuthor: Vincent Ecuyer Contents:1. Purpose2. Usage 3. Examples 4. Commented Code 1. Purpose
2. Usage
3. Examples; save a posterized version of a picture save/png %img-dest.png posterize load %img-src.png 3 ; directly used in a display view layout [ image posterize load http://www.rebol.com/view/demos/nyc.jpg 1 effect [multiply 255] ] 4. Commented Codeposterize: func [ "Applies a posterize effect (color reduction) and returns the result." value [image!] "Source image." depth [integer!] "Color depth: bits / color channel." /local t ][ ; ands the source with a mask having only the most significant bits left value and make image! reduce [ ; same size as the source value/size ; trashes the n (= depth) least significant bits with an ; integer division and multiplication 255.255.255 / (t: 2 ** (8 - depth)) * t ] ] |
MakeDoc2 by REBOL - 31-Jan-2013 |