'''LRIPhoto''' is a package for Tk written with critcl for fast handling of Tk images.
After loading, (with package require LRIPhoto) the current version provides two commands :
======
::LRI::imgtransform imgTk ?-rotate angle? ?-scale scale? ?-gray boolean? ?-bw boolean?
======
and
======
::LRI::imgcopy imgTkSrc imgTkDest ?-rotate angle? ?-scale scale? ?-gray boolean? ?-bw boolean?
======
The manipulations are identical for both commands, except that '''imgtransform''' modifies an image while '''imgcopy''' modifies imgTkDest without touching the source image imgTkSrc.
In any case, the images must exist before invoking the commands.
'''Effects of the commands :'''
======
-rotate angle ; # rotates the image by $angle degrees (0, 90, 180 or 270° only).
-scale scale ; # adjusts the image size to $scale % of its nominal size (scale must be an integer).
-scalex scale ; # adjusts the width of the image to $scale % of its nominal size (scale must be an integer).
-scaley scale ; # adjusts the height of the image to $scale % of its nominal size (scale must be an integer).-gray boolean gray ; # switches the image to grayscale (accepts 0, 1, true or false).
-bw boolean ; # passes the image in rasterized black and white (accepts 0, 1, true or false).
======
Please note the following:
::LRI::imgcopy imgTkSrc imgTkDest
Used without option, imgcopy just copies the imgTkSrc image into imgTkDest
'''Download :'''
http://wfr.tcl-lang.org/files/LRIPhoto.zip
The archive includes pre-compiled binaries for linux (32 and 64 bits), Windows (32 and 64 bits) and Mac OSX (32 and 64 bits); [critcl] sources are also included.
Any contributions (improvements, new features, or binaries for other platforms) are welcome.
'''License :'''
This extension is placed under [OLL] license.
Here is a small test program to test the effects ofand speed :
======
package require Tk
catch {package require Img} ; # Without you can only works with PNG & GIF.
package require LRIPhoto
# var
variable ::imgN none
variable ::angle 0
variable ::gray 0
variable ::bw 0
variable ::scale 100
image create photo imgTkDest
# Procs
proc openImage {} {
set ext { {{Images} {*.gif *.bmp *.tif *.jpg *.jpeg *.png *.pcx}}
}
set title "Choose a bitmap"
catch "image delete imgTkSrc"
set baseimg [tk_getOpenFile -filetypes $ext -title $title -parent .]
if {[file exists $baseimg] && ![catch {image create photo imgTkSrc -file $baseimg}]} {
set ::imgN [file tail $baseimg]
.do configure -state normal
update
} else {
set ::imgN none
.do configure -state disabled
update
}
}
proc DoIt {} {
catch "::LRI::imgcopy imgTkSrc imgTkDest -rotate $::angle \
-scale $::scale -gray $::gray -bw $::bw"
}
# Gui
wm title . "LRIPhoto demo"
grid [frame .f1] -sticky w
button .f1.b -text image -command openImage
label .f1.i -textvariable ::imgN
grid .f1.b .f1.i -sticky w
grid [frame .f2] -sticky w
label .f2.l -text "Angle :"
radiobutton .f2.a0 -text 0° -value 0 -variable ::angle
radiobutton .f2.a90 -text 90° -value 90 -variable ::angle
radiobutton .f2.a180 -text 180° -value 180 -variable ::angle
radiobutton .f2.a270 -text 270° -value 270 -variable ::angle
grid .f2.l .f2.a0 .f2.a90 .f2.a180 .f2.a270 -sticky w
scale .s -label "scale (%)" -from 1 -to 200 -showvalue 1 -variable ::scale \
-orient horizontal -relief raised
grid .s -sticky ew
grid [frame .f3] -sticky w
label .f3.l -text "Convert to :"
checkbutton .f3.g -text Gray -variable ::gray
checkbutton .f3.b -text B&W -variable ::bw
grid .f3.l .f3.g .f3.b -sticky w
grid [button .do -text Process -command DoIt -state disabled] -sticky we
grid [label .l -image imgTkDest]
======