![]() |
oneliner-image-to-pgm.rAuthor: Vincent Ecuyer Contents:1. to-pgm1.1 Purpose 1.2 Usage 1.3 Example 1.4 Commented Code 2. alpha-to-pgm 2.1 Purpose 2.2 Usage 2.3 Example 2.4 Commented Code 1. to-pgm1.1 Purpose
1.2 Usageto-pgm value (image!) channel ('r, 'g, or 'b) 1.3 Example
1.4 Commented Codeto-pgm: func [ "Converts an image RGB channel to a PGM binary format" value [image!] "Image source" channel [word!] "Selected channel: 'r, 'g, or 'b" ] [ ; equivalent to "to-binary rejoin" : we want a binary! result join #{} [ ; the binary PGM file header, followed by a <space> "P5 " ; the image size, in the form width <space> height replace form value/size "x" " " ; a <space>, the max gray value, and a <newline> " 255^(0A)" ; selects only one channel (r, g, or b) and skips others extract/index value/rgb 3 index? find [r g b] channel ] ] 2. alpha-to-pgm2.1 Purpose
2.2 Usagealpha-to-pgm value (image!) 2.3 Examplewrite/binary %imageTest-alpha.pgm alpha-to-pgm logo.gif 2.4 Commented Codealpha-to-pgm: func [ "Converts the alpha channel of an image to a PGM binary format" value [image!] "Image source" ] [ ; equivalent to "to-binary rejoin" : we want a binary! result join #{} [ ; the binary PGM file header, followed by a <space> "P5 " ; the image size, in the form width <space> height replace form value/size "x" " " ; a <space>, the max gray value, and a <newline> " 255^(0A)" ; the alpha channel value/alpha ] ] |
![]() | MakeDoc2 by REBOL - 29-Jan-2013 |