This is a child page. You can use Parent in the quick nav bar at the top or the bottom of the page to navigate directly back to the parent of this page. Some child pages are more than one level deep, and in that case will require more than one Parent click to reach the outermost document level.

§ 16.96.12 - Working with Image Data in your scripts

CALCULATE(PTM$,Opacity,PRESERVE,INVERTA,INVERTB,MASK,R,G,B,A)

This command performs a calculation between the current image and the image on the top of the stack. The current image is replaced by the result of the calculation. The image on the stack is not affected by the calculation.

$PTM is a string that specifies the pixel transfer mode to be used for the calculation. The following PTM's are available:

  • Matte
  • Additive
  • Addgray
  • AbsSubtract
  • Subtract
  • Subgray
  • Multiply
  • Divide
  • Dodge
  • Burn
  • Express
  • Exclude
  • HardLight
  • SoftLight
  • Overlay
  • Lighten
  • Darken
  • Hue
  • Saturation
  • Luma
  • Color
  • Clear
  • Behind
  • Dye
  • Dissolve
  • SoftDissolve
  • Mist
  • SoftMist
  • And
  • Or
  • Xor
  • Nand
  • Nor
  • Xnor

Opacity is a value from 0 to 100%. PRESERVE is a flag, that when set to 1, will cause the transparency of the active image to be preserved. INVERTA is a flag, that when set to 1, causes the active image to be inverted prior to the calculation. INVERTB is a flag, that when set to 1, causes the image on the top of the stack to be inverted prior to the calculation. MASK is a flag that, when set to 1, causes the calculation to be performed using the current mask rather than for every pixel in the image regarless of the mask. R, G, B and A are flags that, when set to 1, cause those specific channels to be included in the calculation. If all of R, G B and A are set to 0, the CALCULATE command will have no effect.

o=SETOFFSET(level)

This command specifies the level for the ADDGRAY and SUBGRAY pixel transfer modes. The default level is 128, set whenever F/x starts. The previous value of the offset is returned from the function. The idea is that if you change this during the course of your script, you can save this value and then restore it when the script completes so the user's calculations using ADDGRAY and SUBGRAY aren't globally affected by the simple fact that your script ran once. You would do this:

10 o = SETOFFSET(22):REM set custom offset 20 REM do a bunch stuff 30 z = SETOFFSET(o):REM restore original offset, whatever it was

a$=SETPTM("name")

a$=SETCTM("name") [returns previous mode as string] (synonym for SETPTM)

This allows you to set the pixel (color) transfer modes. This will affect a number of operators, most importantly (for most scripts) texture and color fill operators.

Scripts should use the previous mode return feature to ensure that F/x is set back to the initial mode it was in when the script was called. This will avoid annoying and inconveniencing users of scripts you write (including you!) Use SETPTM() like this:

10 M$ = SETPTM("LIGHTEN") 20 REM do a bunch of script stuff using lighten 30 X$ = SETPTM("MATTE") 40 REM Now use matte, we'll be ignoring X$ 50 X$ = SETPTM("MULTIPLY") 60 REM now use multiply 70 REM now we're done, so... 80 X$ = SETPTM(M$) 90 REM original mode is politely restored

You may use the following strings for the names (upper and lower case do not matter, case is used simply for clarity here):

  • Matte
  • Additive
  • Addgray
  • AbsSubtract
  • Subtract
  • Subgray
  • Multiply
  • Divide
  • Dodge
  • Burn
  • Express
  • Exclude
  • HardLight
  • SoftLight
  • Overlay
  • Lighten
  • Darken
  • Hue
  • Saturation
  • Luma
  • Color
  • Clear
  • Behind
  • Dye
  • Dissolve
  • SoftDissolve
  • Mist
  • SoftMist
  • And
  • Or
  • Xor
  • Nand Nor
  • Xnor

a=GETALPHA(x,y)

Returns 0-255 value from the action image alpha channel.

a=GETALPHAU(x,y) (retrieves data from the undo buffer)

Returns 0-255 value from the alpha channel of the unmodified copy of the action image in the undo buffer.

a=GETBLUE(x,y)

Returns 0-255 value from the action image blue channel.

a=GETBLUEU(x,y) (retrieves data from the undo buffer)

Returns 0-255 value from the blue channel of the unmodified copy of the action image in the undo buffer.

a=GETGREEN(x,y)

Returns 0-255 value from the action image green channel.

a=GETGREENU(x,y) (retrieves data from the undo buffer)

Returns 0-255 value from the green channel of the unmodified copy of the action image in the undo buffer.

a=GETHUE(x,y)

Returns 0-359 degrees from the action image pixel.

a=GETHUE(x,y) (retrieves data from the undo buffer)

Returns 0-359 degrees from the pixel in the unmodified copy of the action image in the undo buffer.

a=GETLUMA(x,y)

Returns luma level as 0-255 from action image pixel.

a=GETLUMAU(x,y) (retrieves data from the undo buffer)

Returns luma level as 0-255 from unmodified copy of the action image in the undo buffer.

a=GETRED(x,y)

Returns 0-255 value from the action image red channel.

a=GETREDU(x,y) (retrieves data from the undo buffer)

Returns 0-255 value from the red channel of the unmodified copy of the action image in the undo buffer.

a=GETSAT(x,y)

Returns saturation as 0-100 from the action image.

a=GETSATU(x,y) (retrieves data from the undo buffer)

Returns saturation as 0-100 from the unmodified copy of the action image in the undo buffer.

a=PUTALPHA(x,y,value) (returns previous value)

Writes alpha as 0-255 to the action image.

a=PUTBLUE(x,y,value) (returns previous value)

Writes blue channel as 0-255 to the action image.

a=PUTGREEN(x,y,value) (returns previous value)

Writes green channel as 0-255 to the action image.

a=PUTHUE(x,y,value) (returns previous value)

Writes hue as 0-359 to the action image.

a=PUTLUMA(x,y,value) (returns previous value)

Writes luma as 0-255 to the action image.

a=PUTRED(x,y,value) (returns previous value)

Writes red channel as 0-255 to the action image.

a=PUTSAT(x,y,value) (returns previous value)

Writes saturation as 0-100 to the action image.

Keyboard Navigation
, Previous Page . Next Page t TOC i Index o Operators g Glossary
WinImages F/x, Morph and all associated documentation
Copyright © 1992-2007 Black Belt Systems ALL RIGHTS RESERVED Under the Pan-American Conventions
WinImages F/x Manual Version 7, Revision 6, Level A

Valid HTML 4.01 Loose
 

This manual was generated with wtfm
wtfm uses aa_macro and SqLite
aa_macro uses python 2.7
Page 270
box