' Watermark Text Example ' This Queue script will print several lines ot text in the image ' in a pattern over the image to 'watermark' it so it cannot be reproduced ' Requires QFX 8.06 or better for full functionality (see below) ' Get the program version ' Note: if QFX version is less than 8.06, the 'Prepend Copyright ' symbol' box will not appear in Form dialog because earlier ' versions could not handle special characters or symbols ' created by the ObjText command or entered in dialog controls Gosub CheckVersion ' Make sure we have an image If Len('$ImageFullName') = 0 [MSGBOX] Name="" Prompt="Please open an image!" Title="Watermark Text" Buttons=Ok Icon=Exclamation [QUIT] EndIf ' Determine if in Paint or Draw mode If StrCmp( '$ImageMode', 'Paint' ) = 0 $Mode = 0 Else $Mode = 1 EndIf ' Calculate the default font size to be 1/15 of the ' smaller of the image width vs height ' multiply by 72 to convert to 'points' $T = min( $ImageWidth, $ImageHeight ) / 15 $Size = ($T / $ImageYDpi) * 72 ' Init 'Repeat' spin button value relative to font height $Repeat = $ImageHeight / ($T * 5) ' Make sure no Lassos in Paint mode or ' no objects selected if in Draw mode If $Mode = 0 LassoNew Else EditDeselectAll EndIf ' This variable gets set if in Paint mode and 'Blind Emboss' ' box is checked $BlindEmboss = 0 ' This variable gets set if 'Add Copyright' box checked $AddCopyr = 0 ' Put up Form dialog and get user response [FORM] Title="Watermark Text" Size=100,40 Posn=-1,-1 Help="" [INPUTBOX] Name="Text" Value="Enter Text Here" Prompt="Text" Size=120,10 Posn=-1,-1 Style=Normal $SBposn = 30 If $Vers >= 806 [INPUTCHECK] Name="AddCopyr" Value="0" Prompt="Prepend Copyright symbol ©" Posn=-1,-1 $SBposn = $SBposn + 12 EndIf [INPUTLIST] Name="Font" List="Arial,Times New Roman" Value="Arial" Prompt="Font" Size=80,40 Posn=-1,-1 Style=DropDown [INPUTCOLOR] Name="Color" Value="255,255,255" Prompt="Color" Size=16,16 Posn=-1,-1 Type=Default [INPUTSPIN] Name="Size" Value="$Size" Prompt="Point Size" Size=25,12 Posn=123,$SBposn Min="1" Max="400" Decimal=0 Incr="1" [INPUTSPIN] Name="Transp" Value="95" Prompt="Transparency (0-255)" Size=25,12 Posn=-1,-1 Min="0" Max="255" Decimal=0 Incr="1" If $Mode = 0 [INPUTCHECK] Name="BlindEmboss" Value="$BlindEmboss" Prompt="Blind Emboss" Posn=-1,-1 EndIf [INPUTSPIN] Name="Repeat" Value="$Repeat" Prompt="Times to Repeat" Size=25,12 Posn=-1,-1 Min="1" Max="25" Decimal=0 Incr="1" [FORMEND] ' Set option to remove lassos from image after applied [OPTIONS] StashLasso=Yes If $BlindEmboss = 1 ' erase any alpha channel in image MaskErase ' suspend Undo EditUndoSuspend EndIf ' Set Text options to select font and size TextOptions Font="$Font" Size=$Size Width=100 Align=Left WordSpacing=50 Track=10 Space=0 Bold=No Ital=No AutoKern=Yes ' Set object fill, color, edge, transparency, etc. ApplyColor ApplyEdges Style=None ApplyShadow Cast=None ApplySoftness Soft=0 ApplyTransparency Trans=$Transp CalculateNormal If StrCmp( '$ImageModel', 'CMYK' ) = 0 ColorPrimary CMYK=$Color Else ColorPrimary RGB=$Color EndIf ' turn on all color planes ImageColorPlane Model=RGB Red=On Grn=On Blu=On Alf=On Cya=On Mag=On Yel=On Blk=On CmykAlf=On Rand=0,0,0,0 ' Define the Copyright symbol if option selected If $AddCopyr = 1 $Copyr = Chr(169) Else $Copyr = "" EndIf ' Draw the text ObjText Text="'$Copyr'+'$Text'" File=No Locate=0,0 ' If in Paint mode, select the Lasso text because it ' is not automatically selected after it is drawn If $Mode = 0 EditSelectAll EndIf ' Make a copy of the text lasso or object If $Mode = 0 LassoCopy Else EditCopy EndIf ' distribute lines evenly throughout image height $Yt = $ImageHeight - ( $ObjectHeight * $Repeat * 2 ) $Yt = $Yt / ($Repeat * 2 + 1) ' calc amount to increment y each time $Yinc = $Yt + $ObjectHeight ' convert starting position to top origin $Y = $ImageHeight - $Yinc ' set 'x' margin same as space between lines of text $Xmargin = $Yt $X = $Xmargin $Xinc = $ObjectWidth + $X ' Save object width in our own variable $Owidth = $ObjectWidth ' Start 'y' loop that positions text vertically [LOOP] Start=0 Incr=1 Times=$Repeat*2 Name="Yloop" ' start 'x' loop that positions text horizontally ' Note: we set 'Times=' arg to a large value ' because we 'break' out of this loop when ' the text goes past the edge of the image [LOOP] Start=0 Incr=1 Times=100 Name="Xloop" ' Postition the text EditObjectProperties TransCtr=No Locate=$X,$Y ' Paste a copy of the text lasso or object If $Mode = 0 LassoPaste Else EditPaste EndIf ' for even numbered rows, bump text to right ' otherwise bump to left If ($Yloop mod 2) = 0 $X = $X + $Xinc ' if new 'x' position places text beyond right ' edge of image, reset to right edge and break ' out of the 'x' loop If $X + $Owidth + $Xmargin > $ImageWidth $X = $ImageWidth - $Owidth - $Xmargin Break EndIf Else $X = $X - $Xinc ' if new 'x' position places text beyond leftt ' edge of image, reset to left edge and break ' out of the 'x' loop If $X < $Xmargin $X = $Xmargin Break EndIf EndIf [LOOPEND] ' bump y posn down $Y = $Y - $Yinc [LOOPEND] ' Delete last lasso or object If $Mode = 0 LassoClear Else EditClear EndIf ' If 'blind emboss' option checked... If $BlindEmboss = 1 ' turn off RGB or CMYK planes so only alpha channel ' is generated and make sure transparency ' is at 255 so we get a solid alpha channel If StrCmp( '$ImageModel', 'CMYK' ) = 0 ImageColorPlane Cya=Off Mag=Off Yel=Off Blk=Off CmykAlf=On Else ImageColorPlane Red=Off Grn=Off Blu=Off Alf=On EndIf ApplyTransparency Trans=255 EndIf ' Make sure alpha mask is off ImageAlphaMask State=Off Mode=In/Add Value=255 ' If in Paint mode, apply the text and remove the Lasso ' otherwise deselect text object in Draw mode If $Mode = 0 LassoOptions Fill=Inside AntiAlias=Yes Softness=0 EditApplyTool LassoNew Else EditDeselectAll EndIf ' If 'blind emboss' option selected, do the emboss effect If $BlindEmboss = 1 ' turn on all color planes ImageColorPlane Model=RGB Red=On Grn=On Blu=On Alf=On Cya=On Mag=On Yel=On Blk=On CmykAlf=On Rand=0,0,0,0 ' calc size of emboss relative to image size $Esize = min( $ImageHeight, $ImageWidth ) / 500 If $Esize < 1 $Esize = 1 EndIf ' setup the emboss EfxEmboss Size=$Esize Angle=315 Place=Under HiColr=238,238,238 HiCMYK=0,0,0,17 LoColr=51,51,51 LoCMYK=0,0,0,204 ' do the emboss ApplyTransparency Trans=255 ApplyEfx EditApplyFull ' resume Undo EditUndoResume EndIf [QUIT] ' This subroutine gets the program version number ' To handle versions that do not understand the ' $ApplicationVersion global, we turn on error logging ' (so no error msg printed) and trap all errors to the ' VersionError handler routine which sets the version ' to the first 8.0 release version CheckVersion: ' turn on error logging [LOG] Filename="QUEUE.LOG" TimeStamp=No LogLines=No ' set error handler [ERRORGOTO] VersionError ' try to get version number from global $Vers = $ApplicationVersion ' turn of error handler [ERRORGOTO] ' turn off error logging [LOG] [RETURN] ' Handles error if $ApplicationVersion global not found VersionError: ' set first version and resume on line after error $Vers = 800 [RESUMENEXT]