• Get Negative of any image i.e. black to white and white to black &so.on

    From Conor Williams@21:1/5 to All on Mon Oct 11 18:58:48 2021
    ############ ############ ############
    # conor.williams@gmail.com
    # tcl script to tell ... 202109211923
    #e.g. http://solvedissues.000webhostapp.com/ss4.png
    ############ ############ ############
    set age 0
    proc rest123 {filename} {
    set img [image create photo img -file $filename]
    catch {
    canvas .con
    .con create image 0 0 -anchor nw -image $img
    pack .con
    update
    }

    set myvar 1
    wm title . "Negatize"
    catch {destroy .but}
    ######## ######### ########
    # Main Procedural Loop
    ######## ######### ########
    set flag 0
    set whiteFound 0
    set imax [image width $img]
    set jmax [image height $img]
    for {set i 0} {$i < $imax} {incr i 1} {
    for {set j 0} {$j < $jmax} {incr j 1} {
    set data [$img get $i $j]
    puts $data
    set red1 [expr 255 - [lindex $data 0]]
    set green2 [expr 255 - [lindex $data 1]]
    set blue3 [expr 255 - [lindex $data 2]]
    set newcolor [format "#%03d%03d%03d" $red1 $green2 $blue3]
    puts "$i $j $newcolor"
    puts $newcolor
    $img put $newcolor -to $i $j
    update
    }
    }

    }

    frame .frame1
    pack .frame1 -side top
    label .frame1.filename -text "png filename 2n:"
    pack .frame1.filename -side left
    text .frame1.text2 -height 1 -width 30
    pack .frame1.text2 -side right
    #KeyPress is the event not the binding
    #.frame1.text2 tag bind KeyPress {rest123 [.frame1.text2 get -displaychars 1.0 1.100]}
    button .but10
    .but10 configure -text "press me" -command {rest123 [.frame1.text2 get -displaychars 1.0 1.100]}
    pack .but10
    update
    #########
    #EOF
    ##########

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)