pkg://ikit-0.4-1.sparc.rpm:138064/
usr/
local/
lib/
ikit/ikit_tiff.tcl
info downloads
#
# Copyright (c) 1997 Picture Elements, Inc.
# Stephen Williams (steve@picturel.com)
#
# This source code is free software; you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# Library General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option)
# any later version. In order to redistribute the software in
# binary form, you will need a Picture Elements Binary Software
# License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc.,
# 59 Temple Place - Suite 330
# Boston, MA 02111-1307, USA
#
# You should also have recieved a copy of the Picture Elements
# Binary Software License offer along with the source. This offer
# allows you to obtain the right to redistribute the software in
# binary (compiled) form. If you have not received it, contact
# Picture Elements, Inc.,
# 777 Panoramic Way
# Berkeley, CA 94704.
#
#ident "$Id: ikit_tiff.tcl,v 1.7 1997/02/03 20:09:08 steve Exp $"
#
# $Log: ikit_tiff.tcl,v $
# Revision 1.7 1997/02/03 20:09:08 steve
# console message output interface.
#
# Revision 1.6 1997/02/01 06:35:22 steve
# Support tiled gray images, and support RGB true
# color tiff input.
#
# Revision 1.5 1997/01/31 23:32:07 steve
# More descriptive image labels.
#
# Revision 1.4 1997/01/28 06:10:40 steve
# Support compression of TIFF files.
#
# Revision 1.3 1997/01/25 06:41:06 steve
# Create a general purpose parameter reader,
# support file completion, get integer values.
#
# Revision 1.2 1997/01/21 05:02:37 steve
# Better TIFF error message handling,
# Put the loader and saver in the package script
#
# Revision 1.1 1997/01/21 03:30:24 steve
# Add the ik_store command, and the ability for
# TIFF files to be stored. Also, add a preferences
# menu item and functions to populate it.
#
# --
# Set up the TIFF stuff, including all the global functions
# needed. Install hooks into the GUI as needed.
#
toplevel .pref_tiff
label .pref_tiff.title -text "TIFF Preferences"
frame .pref_tiff.bin_comp
label .pref_tiff.bin_comp.label -text "Binary compression:"
radiobutton .pref_tiff.bin_comp.none -text "None" \
-variable tiff_bin_comp \
-value none
radiobutton .pref_tiff.bin_comp.faxg3 -text "Fax G3" \
-variable tiff_bin_comp \
-value ccitt-fax3
radiobutton .pref_tiff.bin_comp.faxg4 -text "Fax G4" \
-variable tiff_bin_comp \
-value ccitt-fax4
pack .pref_tiff.bin_comp.label \
.pref_tiff.bin_comp.none \
.pref_tiff.bin_comp.faxg3 \
.pref_tiff.bin_comp.faxg4 \
-side left -anchor nw
frame .pref_tiff.gray_comp
label .pref_tiff.gray_comp.label -text "Gray compression:"
radiobutton .pref_tiff.gray_comp.none -text "None" \
-variable tiff_gray_comp \
-value none
radiobutton .pref_tiff.gray_comp.defl -text "Deflate" \
-variable tiff_gray_comp \
-value deflate
radiobutton .pref_tiff.gray_comp.lzw -text "LZW" \
-variable tiff_gray_comp \
-value lzw
pack .pref_tiff.gray_comp.label \
.pref_tiff.gray_comp.none \
.pref_tiff.gray_comp.defl \
.pref_tiff.gray_comp.lzw \
-side left -anchor nw
button .pref_tiff.dismiss -text "dismiss" -command {wm withdraw .pref_tiff}
pack .pref_tiff.title \
.pref_tiff.bin_comp \
.pref_tiff.gray_comp \
.pref_tiff.dismiss \
-side top
ik_add_preference "TIFF" .pref_tiff
set tiff_bin_comp "ccitt-fax4"
set tiff_gray_comp "deflate"
# --
# Load a TIFF file into an image, and push the result onto the top
# of the stack.
set tiff_file_load ""
proc tiff_load {} {
global tiff_file_load
ik_get_values "{tiff_file_load {TIFF file to load:} filename}"
set file "$tiff_file_load"
set label [ik_unique_image_name [file tail $tiff_file_load]]
set msg [time {image create ik_image $label -tiff $file}]
set msg "Loaded in [lindex $msg 0] usec\n"
ik_stack_push $label "$label <-- TIFF($file)\n" "$msg"
}
# --
# Save an image into a TIFF file.
set tiff_file_save ""
proc tiff_save {} {
global tiff_file_save tiff_gray_comp tiff_bin_comp
set source [ik_stack_peek]
if {[llength $source] == 0} return
ik_get_values "{tiff_file_save {TIFF file to save:} filename}"
set file "$tiff_file_save"
ik_store $source -tiff $file \
-comp-gray $tiff_gray_comp \
-comp-bin $tiff_bin_comp
ik_console "Store $source in TIFF file $file\n"
}
ik_add_saver "TIFF" tiff_save
ik_add_loader "TIFF" tiff_load