Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

REBOL/Power-Tools/Graphics INVERT-IMAGE function!

 [1/7] from: robbo1mark::aol::com at: 1-Mar-2001 6:32


More REBOL/Power-Tools, here a little graphics function which inverts an image file and saves to a new file, after previewing the inverted image, requires REBOL/View. invert-image: func [image [file! url!] target [file! url!]][ image: load image new-pic: make image! image/size i: 1 repeat this (image/size/x * image/size/y) [ poke new-pic i complement pick image 1 i: i + 1 image: next image] face/image: new-pic face/size: new-pic/size view face save target new-pic ] cheers, mark Dickson

 [2/7] from: robbo1mark:aol at: 1-Mar-2001 6:53


IMPORTANT BUG FIX NOTICE! change last line to; save/png target new-pic or alternatively; save/bmp target new-pic depending upon your graphic file format preference. cheers, Mark Dickson In a message dated Thu, 1 Mar 2001 6:46:12 AM Eastern Standard Time, [Robbo1Mark--aol--com] writes: << More REBOL/Power-Tools, here a little graphics function which inverts an image file and saves to a new file, after previewing the inverted image, requires REBOL/View. invert-image: func [image [file! url!] target [file! url!]][ image: load image new-pic: make image! image/size i: 1 repeat this (image/size/x * image/size/y) [ poke new-pic i complement pick image 1 i: i + 1 image: next image] face/image: new-pic face/size: new-pic/size view face save target new-pic ] cheers, mark Dickson

 [3/7] from: jeff:rebol at: 1-Mar-2001 5:44


invert-image: func [ im [file!] target [file!] ][ save/png target to-image view make face [ image: load-image im size: image/size effect: 'invert ] ]

 [4/7] from: robbo1mark:aol at: 1-Mar-2001 9:34


Jeff, Your solution is much more elegant in it's use of the visual interface dialect effect 'invert, however what I was trying to show that is indeed still possible to write graphics routines and functions that albeit slower are still functional using basic core commands without using black-box functions like the VID in-built effects. Hope this clears the confusion. Mark Dickson In a message dated Thu, 1 Mar 2001 8:59:44 AM Eastern Standard Time, [jeff--rebol--net] writes: << invert-image: func [ im [file!] target [file!] ][ save/png target to-image view make face [ image: load-image im size: image/size effect: 'invert ] ]

 [5/7] from: jeff:rebol at: 1-Mar-2001 7:02


invert-image: func [ im [file! url!] tg [file!] /local f ][ im: load-image im f: make face [font: para: edge: none color: white size: im/size] save/png tg to-image view make f [image: im xor to-image f] ]

 [6/7] from: robbo1mark:aol at: 1-Mar-2001 11:08


JEFF, fantastic - maximum productivity - minimal expression! this is REBOL at it's best! query? how long have op!'s been useable with image! types.
>> ? xor
USAGE: value1 XOR value2 DESCRIPTION: Returns the first value exclusive ORed with the second. XOR is an op value. ARGUMENTS: value1 -- (Type: logic number char tuple) value2 -- (Type: logic number char tuple)
>>
It doesn't mention this in the docs or help? cheers, Mark In a message dated Thu, 1 Mar 2001 10:22:55 AM Eastern Standard Time, [jeff--rebol--net] writes: << invert-image: func [ im [file! url!] tg [file!] /local f ][ im: load-image im f: make face [font: para: edge: none color: white size: im/size] save/png tg to-image view make f [image: im xor to-image f] ]

 [7/7] from: jeff:rebol at: 2-Mar-2001 6:55


Core release notes mentions change to the logical operators. I think the view release notes also mentioned it. If it doesn't show up in later documentation then that's a doc bug. http://www.rebol.com/core23notes.html
> query? how long have op!'s been useable with image! types. > >> ? xor
<<quoted lines omitted: 6>>
> value1 -- (Type: logic number char tuple) value2 -- > (Type: logic number char tuple)
Internal doc bug. Be sure to submit this kind of stuff to feedback so Bo can bug someone to fix it at some point. In this case it's not necessary since I fixed it right now for future builds. Thanks. -jeff

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted